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 SAA02030 for caml-red; Thu, 11 Jan 2001 18:30:03 +0100 (MET) 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 LAA02034 for ; Thu, 11 Jan 2001 11:32:54 +0100 (MET) Received: from mail1.microsoft.com (mail1.microsoft.com [131.107.3.125]) by concorde.inria.fr (8.11.1/8.10.0) with SMTP id f0BAWqj15098 for ; Thu, 11 Jan 2001 11:32:53 +0100 (MET) Received: from 157.54.9.101 by mail1.microsoft.com (InterScan E-Mail VirusWall NT); Thu, 11 Jan 2001 02:30:16 -0800 (Pacific Standard Time) Received: from na-hub-03.redmond.corp.microsoft.com ([157.54.2.50]) by inet-imc-01.redmond.corp.microsoft.com with Microsoft SMTPSVC(5.0.2195.1600); Thu, 11 Jan 2001 02:31:52 -0800 Received: from corp-hub-01.redmond.corp.microsoft.com ([157.54.2.41]) by na-hub-03.redmond.corp.microsoft.com with Microsoft SMTPSVC(5.0.2195.1600); Thu, 11 Jan 2001 02:32:48 -0800 Received: from TVP-MSG-02.europe.corp.microsoft.com ([157.58.33.54]) by corp-hub-01.redmond.corp.microsoft.com with Microsoft SMTPSVC(5.0.2195.1600); Thu, 11 Jan 2001 02:32:48 -0800 X-MIMEOLE: Produced By Microsoft Exchange V6.0.4418.12 Content-Class: urn:content-classes:message Subject: RE: first class, recursive, mixin modules (was: RE: first class modules) MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Date: Thu, 11 Jan 2001 10:32:43 -0000 Message-ID: <112C6E8A1B25D34BB27D48D2FD2E96CFC9DED4@TVP-MSG-02.europe.corp.microsoft.com> Thread-Topic: first class, recursive, mixin modules (was: RE: first class modules) Thread-Index: AcB7TUMIsCQpaXm8Riy3wnDRXR2ysQAZyPpQ From: "Claudio Russo" To: "Alain Frisch" Cc: "Brian Rogoff" , "Caml list" X-OriginalArrivalTime: 11 Jan 2001 10:32:48.0110 (UTC) FILETIME=[D78110E0:01C07BB9] Sender: weis@pauillac.inria.fr > Are there real examples using recursive modules with these=20 > restrictions ? Well, it depends on what do you mean by real... They are useful, together with first-class modules, for doing object encodings (albeit rather heavy ones).=20 You get polymorphic recursion for free (but at the cost of the dynamic check, which could be optimized away in this case), but there are simpler mechanisms for this. Chris Okasaki's elegant bootstrapped heap implementation requires them (+ other features) (see the mosml distribution). They are probably useful for things like CORBA to ML bindings that use the ML modules language to capture the structure of the mutually recursive IDL interfaces.=20 An then there's the example of the Ocaml modules/core typechecker that you mention. > You can always define everything outside the structures (or=20 > in the first > one), then copy the types and values in the structures. Of course, you > loose the modularity of definitions, but with recursive modules as in > MosML, you loose the static typing for the module language (Bind > exceptions) and also the modularity (different source files; > separate compilation).=20 I'm not sure what you meant by losing static typing. It's just that typing for recursive modules now gives you a weaker property --- either the recursive expression evaluates or raises the exception Bind. It never seg faults. I think it would be possible to refine the type system to detect unsafe recursion and avoid dynamic checks for safe recursion, but this is alot more work and may well interact with other features of the type system. Note that it is already possible to use a syntactic criterion to avoid some dynamic checks (something like those under functions that don't get called in the recursive module), as an optimisation. And of course, you can always still use the reference tying trick of Ocala. > If you accept runtime checks, the solution adopted > in the OCaml compiler to break the circle of dependencies between > the Core and Module type checkers (forward declaration with a=20 > reference > updated when the definition is available) has the advantage=20 > of retaining > separate compilation. But this only works for mutually recursive functions that span module boundaries, not datatype definitions. You'll note in the caml sources that the abstract syntax tree and typed abstract syntax tree for module are defined in a single datatype definition, not separately. Although it's possible to separate them out using type parameters, this is pretty inconvenient in practice.=20 > Back to first class packaged modules: a very useful feature=20 > for runtime > configuration of applications would be the possibility to load the > packages from the disk/network (that is, dynamic loading; the > signature of trusted packages can be checked as in the=20 > Dynlink module). This shouldn't be too difficult. I have an example of using that used Moscow ML's Dynlib library to construct an ADT to a C shared library, if it exists, and default ADT otherwise. This is similar to what you want, except for loading a C library. =20 Cheers,=20 Claudio =20