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 TAA19524 for caml-red; Fri, 9 Jun 2000 19:35:24 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA11894 for ; Fri, 9 Jun 2000 10:53:12 +0200 (MET DST) Received: from enseeiht.enseeiht.fr (enseeiht.enseeiht.fr [147.127.18.144]) by concorde.inria.fr (8.10.0/8.10.0) with ESMTP id e598rBn14941 for ; Fri, 9 Jun 2000 10:53:11 +0200 (MET DST) Received: from enseeiht.fr by enseeiht.enseeiht.fr; Fri, 9 Jun 2000 10:52:35 +0200 (MET DST) X-Url: http://www.enseeiht.fr Message-ID: <3940B051.BF1136F7@enseeiht.fr> Date: Fri, 09 Jun 2000 10:52:33 +0200 From: David Chemouil Organization: ENSEEIHT - LIMA/IRIT/CNRS X-Mailer: Mozilla 4.7 [en] (X11; I; SunOS 5.6 sun4u) X-Accept-Language: fr, en MIME-Version: 1.0 To: caml-list@inria.fr Subject: polymorphic variants Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Sender: weis Hi, I and my teammates are currently writing a compiler for a distributed language, called ML-Act, that generates OCaml 3.00 code. I'm involved in the code generation and middleware design. The middleware is made of servers which are, of course, intended to work with many different applications. Each application is likely to send messages through the network. We only find the type of an argument when compiling an ML-Act program. 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. Therefore, the server programs could not be linked, because the type 'argument' can't be created as long as I don't know all the type constructors. So, these server programs should be compiled for a specific application, for which I would have found all possible constructors for an argument. The solution I found is the following one: I use polymorphic variants. Then, the servers use polymorphic constructors, and can be compiled. And for each compiled ML-Act application, I generate a type 'argument' containing, as constructors, the server constructors, plus the constructors found at compilation. However, I wonder if my solution is really good, from a software engineering point of view. Or, on the contrary, is it a good example of why polymorphic variants can be interested. In fact, I wonder how I could have done without this new possibility in OCaml 3.00. -- David Chemouil [mailto:chemouil@enseeiht.fr] [mobile: 06 84 16 26 65] Laboratoire d'informatique et de mathématiques appliquées (IRIT-INPT) "Je vous ai fait trop faibles pour sortir du gouffre, parce que je vous ai fait assez forts pour n'y point tomber" -- Rousseau