From: Markus Mottl <mottl@miss.wu-wien.ac.at>
To: David Chemouil <David.Chemouil@enseeiht.fr>
Cc: OCAML <caml-list@inria.fr>
Subject: Re: polymorphic variants
Date: Fri, 9 Jun 2000 22:03:43 +0200 [thread overview]
Message-ID: <20000609220343.B29376@miss.wu-wien.ac.at> (raw)
In-Reply-To: <3940B051.BF1136F7@enseeiht.fr>; from David.Chemouil@enseeiht.fr on Fri, Jun 09, 2000 at 10:52:33 +0200
Followup to my last mail:
Actually, you need not necessarily double decode things (first the network
message, then the user data): you can do this in one step, too, also using
the Marshal-module.
It does not matter whether you know the internals of the user data or not
(when the type is abstract): the Marshal-module will always do the right
thing during decoding - but make sure that you only pass on the user data
to functions of the right type (i.e. ones that can really handle it),
otherwise your program will crash.
E.g. (recv takes the raw string from the network now):
type admin_args = ...
type user_data (* abstract *)
type argument = MsgA of admin_args * user_data | MsgB of ... | ...
let recv network_data =
let msg : argument = Marshal.from_string network_data 0 in
match msg with
| MsgA (admin_args, user_data) ->
handle_admin_args admin_args;
call_user_program user_data
| ...
...
Best regards,
Markus Mottl
--
Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl
next prev parent reply other threads:[~2000-06-12 14:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-06-09 8:52 David Chemouil
2000-06-09 19:04 ` Markus Mottl
2000-06-09 20:03 ` Markus Mottl [this message]
2007-01-16 20:32 Polymorphic Variants Tom
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20000609220343.B29376@miss.wu-wien.ac.at \
--to=mottl@miss.wu-wien.ac.at \
--cc=David.Chemouil@enseeiht.fr \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox