From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA24385 for caml-red; Mon, 12 Jun 2000 16:02:24 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id WAA15632 for ; Fri, 9 Jun 2000 22:04:22 +0200 (MET DST) Received: from miss.wu-wien.ac.at (miss.wu-wien.ac.at [137.208.107.17]) by nez-perce.inria.fr (8.10.0/8.10.0) with ESMTP id e59K4Lr17494 for ; Fri, 9 Jun 2000 22:04:22 +0200 (MET DST) Received: (from mottl@localhost) by miss.wu-wien.ac.at (8.9.0/8.9.0) id WAA06595; Fri, 9 Jun 2000 22:03:44 +0200 (MET DST) Date: Fri, 9 Jun 2000 22:03:43 +0200 From: Markus Mottl To: David Chemouil Cc: OCAML Subject: Re: polymorphic variants Message-ID: <20000609220343.B29376@miss.wu-wien.ac.at> References: <3940B051.BF1136F7@enseeiht.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2i In-Reply-To: <3940B051.BF1136F7@enseeiht.fr>; from David.Chemouil@enseeiht.fr on Fri, Jun 09, 2000 at 10:52:33 +0200 Sender: weis 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