Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* [Caml-list] questions about marshalling
@ 2001-03-17 14:04 eijiro_sumii
  2001-03-19 10:42 ` Xavier Leroy
  0 siblings, 1 reply; 2+ messages in thread
From: eijiro_sumii @ 2001-03-17 14:04 UTC (permalink / raw)
  To: caml-list; +Cc: sumii

I have questions about marshaling in ocaml-3.0x:

(1) Is it safe to marshal values of a statically polymorphic type, like

      let f x = Marshal.to_channel outchan (x, x) [Marshal.Closures]

    for example, provided that the marshaled values will be unmarshaled as
    values of the right types at runtime?

(2) Is it safe to *un*marshal a value at a statically polymorphic type
    and use it later at a statically monomorphic type, like

      let g x = fst x
      let y : int = g (Marshal.from_channel inchan)

    for example, provided that the value has the right type at runtime?

My guess is that both of these are safe, even though the document says

  The programmer should explicitly give the expected type of the
  returned value, using the following syntax: `(Marshal.from_channel
  chan : type)'.

because the (un)marshaling function itself works on the basis of the
runtime tag rather than the static type of a value -- a catastrophe
may be caused *later* when the value is actually used at a wrong type.
Am I correct?

(3) Yet another question: in a program using marhsaling (via ocamlmpi,
    actually), I get the following error:

      Fatal error: uncaught exception Failure("input_value: ill-formed message")

    What does this mean?  I am quite sure that all the hosts are
    running the same binary, and I am using only ocamlmpi for
    communication.  Does this necessarily mean that I gave a wrong
    type for the unmarshaled value (in Mpi.receive, to be specific),
    or are there other possibilities?  It seems that this assertion
    failure occurs at line 272 in byterun/intern.c, examining the
    runtime tag of the value.

Many thanks in advance,

   Eijiro
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-03-19 10:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-17 14:04 [Caml-list] questions about marshalling eijiro_sumii
2001-03-19 10:42 ` Xavier Leroy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox