From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA14322 for caml-red; Mon, 12 Jun 2000 16:01:31 +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 VAA02670 for ; Fri, 9 Jun 2000 21:05:53 +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 e59J5qr16974 for ; Fri, 9 Jun 2000 21:05:52 +0200 (MET DST) Received: (from mottl@localhost) by miss.wu-wien.ac.at (8.9.0/8.9.0) id VAA00845; Fri, 9 Jun 2000 21:04:59 +0200 (MET DST) Date: Fri, 9 Jun 2000 21:04:59 +0200 From: Markus Mottl To: David Chemouil Cc: caml-list@inria.fr Subject: Re: polymorphic variants Message-ID: <20000609210458.A29376@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 On Fri, 09 Jun 2000, David Chemouil wrote: > The problem is that, as server communicate for admistrative reasons, > they exchange messages with arguments of which I already know the type > constructor. > > As a consequence, the servers must manipulate a type 'argument' which is > not yet completely defined: the part interesting the servers is defined > but not the one interesting the generated OCaml program. Maybe you would want to try something like this (uses the Marshal module): type admin_args = ... type user_data = string type argument = MsgA of admin_args * user_data | MsgB of ... | ... Then you can react to messages as follows, for example: let recv = function | MsgA (adm_args, user_data) -> handle_adm_args adm_args; call_user_program (Marshal.from_string user_data) | MsgB ... -> ... Sending would be something like: let send user_data = let adm_args = create_args () and contents = Marshal.to_string user_data [Closures] in send_network (MsgA (adm_args, contents)) Very rudimentary, but the basic idea (keep user data encoded in a string until needed) should be clear... Best regards, Markus Mottl -- Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl