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 VAA11316 for caml-red; Sun, 14 Jan 2001 21:18:53 +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 SAA04423 for ; Fri, 12 Jan 2001 18:15:59 +0100 (MET) Received: from mail3.microsoft.com (mail3.microsoft.com [131.107.3.123]) by concorde.inria.fr (8.11.1/8.10.0) with SMTP id f0CHFv510451 for ; Fri, 12 Jan 2001 18:15:57 +0100 (MET) Received: from 157.54.9.100 by mail3.microsoft.com (InterScan E-Mail VirusWall NT); Fri, 12 Jan 2001 09:04:17 -0800 (Pacific Standard Time) Received: by inet-imc-03.redmond.corp.microsoft.com with Internet Mail Service (5.5.2651.58) id ; Fri, 12 Jan 2001 09:05:07 -0800 Message-ID: <112C6E8A1B25D34BB27D48D2FD2E96CFC9DED6@TVP-MSG-02.europe.corp.microsoft.com> From: Claudio Russo To: Brian Rogoff , Dave Berry Cc: Alain Frisch , Caml list , kfl@it.edu, sestoft@dina.kvl.dk Subject: RE: first class, recursive, mixin modules (was: RE: first class m odules) Date: Fri, 12 Jan 2001 04:12:03 -0800 X-Mailer: Internet Mail Service (5.5.2651.58) content-class: urn:content-classes:message Sender: weis@pauillac.inria.fr I wasn't quite sure of your intention, but I did get the attached code to work in Mosml (it includes a port of the Ocaml libraries and a fleshed out implementation of your idea). Unfortunately, this only works in an internal release of Moscow, because of a (known) bug in the current distribution. For the record, your functor application Make(Ord)is fine because it is applied to a local, already defined structure. > structure T = rec(X : COMPOSITE) > struct > structure Composite = > struct > datatype t = { data : int ; children : X.CompositeSet.t } > end > structure Ord : Set.OrderedType = > struct > type t = Composite.t > let compare = Pervasives.compare > end > structure CompositeSet = Set.Make(Ord) > end An application like Make(T.Ord), through the forward reference, would raise the Bind exception, because T (and T.Ord) is undefined at that point (although Ord is). -c > -----Original Message----- > From: Brian Rogoff [mailto:bpr@best.com] > Sent: 11 January 2001 20:01 > To: Dave Berry > Cc: Claudio Russo; Alain Frisch; Caml list > Subject: RE: first class, recursive, mixin modules (was: RE: > first class > m odules) > > > My "litmus test" for recursive modules is that it fixes the well known > problem with expressing what OO folk call the Composite pattern, > essentially a recursively defined collection type with a leaf/node > relationship. Here is an approxmation of what I want to do in > "faux-Mosml > with OCaml libraries". Forgive my errors, I don't use SML. The idea > should be clear. > > signature COMPOSITE = > rec(X : sig structure CompositeSet : sig type t end end) > sig structure Composite : > sig > datatype t = > { data : int ; children : X.CompositeSet.t } > end > structure CompositeSet : (Set.S where type elt = Composite.t) > end; > > structure T = rec(X : COMPOSITE) > struct > structure Composite = > struct > datatype t = { data : int ; children : X.CompositeSet.t } > end > structure Ord : Set.OrderedType = > struct > type t = Composite.t > let compare = Pervasives.compare > end > structure CompositeSet = Set.Make(Ord) > end > > This is syntactically heavy, but better than the > parameterization trick > needed now, and I'd be satisfied. I do need to do that functor > instantiation, so if you can't do it in Mosml it needs to be added. > > I agree that the first-class module extension is useful on > its own too, > but in my own programming the problem I mention above arises > frequently > enough that I consider this a flaw of (current) ML style > modules. Every > language has flaws but since OCaml is so close to perfection > every flaw > seems large ;-). > > -- Brian > > On Thu, 11 Jan 2001, Dave Berry wrote: > > > We ran into an example (in SML) during the development of > MLWorks. I can > > only remember it vaguely, but there were two large module > hierarchies. > > These hierarchies were in logically different parts of the > system. A new > > development built on top of these hierarchies meant that we > needed to make > > one element from the bottom of each hierarchy be mutually > recursive with > > each other. I suspect that since we were using a fully > functorised style, > > what we wanted to do was to make two functors mutually > recursive. In > > practice we had to combine the module hierarchies to make > the types and > > values mutually recursive at the bottom of the new hierarchy. > > > > I wish I could remember what the example was, because it > was a clear case > > where the ML module system was too inflexible to meet the > pragmatic needs. > > Imagine how we would have been stuck if the two module > hierarchies were > > libraries from different suppliers, especially if they were > only distributed > > in compiled form. > > > > Dave. > > > > > > -----Original Message----- > > From: Claudio Russo [mailto:crusso@microsoft.com] > > Sent: Thursday, January 11, 2001 10:33 > > To: Alain Frisch > > Cc: Brian Rogoff; Caml list > > Subject: RE: first class, recursive, mixin modules (was: > RE: first class > > modules) > > > > > > > begin 600 composite.sml M*"HJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ M*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*0T**"H@("`@("`@("`@("`@ M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@ M("`@("`@("`@("`J*0T**"H@("`@("`@("`@("`@("`@("`@("`@("`@("!/ M8FIE8W1I=F4@0V%M;"`@("`@("`@("`@("`@("`@("`@("`@("`@("`J*0T* M*"H@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@ M("`@("`@("`@("`@("`@("`@("`@("`@("`J*0T**"H@("`@("`@("`@("!8 M879I97(@3&5R;WDL('!R;VIE="!#&-E<'1I;VX@3F]T7V9O=6YD.PT*9G5N(&EN=F%L:61?87)G M(',@/2!R86ES92`H26YV86QI9%]A7!E(#T-"B`@3H@=`T*("`@('9A;"!I3H@="`M/B!B;V]L#0H@("`@=F%L(&UE M;3H@96QT("T^('0@+3X@8F]O;`T*("`@('9A;"!A9&0Z(&5L="`M/B!T("T^ M('0-"B`@("!V86P@2`]/B`P('P@3F]D92A?+%\L7RQH*2`]/B!H(`T*"2`@=F%L M(&AR(#T@8V%S92!R(&]F($5M<'1Y(#T^(#`@?"!.;V1E*%\L7RQ?+&@I(#T^ M(&@@#0H@("`@("!I;@T*("`@("`@3F]D92AL+"!X+"!R+"`H:68@:&P@/CT@ M:'(@=&AE;B!H;"`K(#$@96QS92!H2X-"B`@("`@("!!"!R(#T-"B`@("`@(&QE="!V86P@:&P@ M/2!C87-E(&P@;V8@16UP='D@/3X@,"!\($YO9&4H7RQ?+%\L:"D@/3X@:"`- M"@D@('9A;"!H2`]/B`P('P@3F]D92A?+%\L M7RQH*2`]/B!H(`T*("`@("`@:6X-"B`@("`@(&EF(&AL(#X@:'(@*R`R('1H M96X@*`T*("`@("`@("!C87-E(&P@;V8-"B`@("`@("`@("!%;7!T>2`]/B!I M;G9A;&ED7V%R9R`B4V5T+F)A;"(-"B`@("`@("`@?"!.;V1E*&QL+"!L=BP@ M;'(L(%\I(#T^#0H@("`@("`@("`@("!I9B!H96EG:'0@;&P@/CT@:&5I9VAT M(&QR('1H96X-"B`@("`@("`@("`@("`@8W)E871E(&QL(&QV("AC"!R*0T*("`@("`@("`@("`@96QS92`H#0H@("`@("`@("`@("`@(&-A M2`]/B!I;G9A;&ED7V%R M9R`B4V5T+F)A;"(-"B`@("`@("`@("`@("`@?"!.;V1E*&QR;"P@;')V+"!L M"!R;"D@"P@2`]/@T*("`@("`@("`@("A% M;7!T>2P@3D].12P@16UP='DI#0H@("`@("!\($YO9&4H;"P@=BP@2`]($5M M<'1Y#0H-"B`@("!V86P@:7-?96UP='D@/2!F;B!%;7!T>2`]/B!T"`]($YO9&4H16UP='DL('@L($5M<'1Y+"`Q*0T*#0H@("`@9G5N M(')E;6]V92!X(#T@9FX-"B`@("`@("`@16UP='D@/3X@16UP='D-"B`@("`@ M('P@3F]D92AL+"!V+"!R+"!?*2`]/@T*("`@("`@("`@(&QE="!V86P@8R`] M($]R9"YC;VUP87)E('@@=B!I;@T*("`@("`@("`@(&EF(&,@/2`P('1H96X@ M;65R9V4@;"!R(&5L2D@/3X@=#$-"B`@("`@('P@*$YO9&4H;#$L('8Q+"!R,2P@ M:#$I+"!.;V1E*&PR+"!V,BP@2D@/3X@16UP='D-"B`@("`@('P@*$YO9&4H;#$L('8Q+"!R,2P@ M7RDL('0R*2`]/@T*("`@("`@("`@(&-A2D@/3X@=#$-"B`@ M("`@('P@*$YO9&4H;#$L('8Q+"!R,2P@7RDL('0R*2`]/@T*("`@("`@("`@ M(&-A"!;2P@7RD@/3X-"B`@("`@("`@("!T2D@/3X-"B`@("`@("`@("!F86QS90T*("`@("`@?"`H3F]D92`H;#$L M('8Q+"!R,2P@7RDL('0R(&%S("A.;V1E("AL,BP@=C(L('(R+"!?*2DI(#T^ M#0H@("`@("`@("`@;&5T('9A;"!C(#T@3W)D+F-O;7!A2P@,"DI(&PR(&%N9&%L2P@=C$L M('(Q+"`P*2D@2`]/B!F86QS90T*("`@("`@?"!.;V1E M*&PL('8L('(L(%\I(#T^('`@=B!O2`] M/B!A8V-U#0H@("`@("`@('P@3F]D92AL+"!V+"!R+"!?*2`]/@T*("`@("`@ M("`@("`@<&%R="`H<&%R="`H:68@<"!V('1H96X@*&%D9"!V('0L(&8I(&5L M2D@"!A8V-U(#T@9FX-"B`@("`@("`@ M16UP='D@/3X@86-C=0T*("`@("`@?"!.;V1E*&PL('8L('(L(%\I(#T^(&5L M96UE;G1S7V%U>"`H=B`Z.B!E;&5M96YT"!;72!S#0H- M"B`@(&9U;B!M:6Y?96QT('@@/2!C87-E('@@;V8-"B`@("`@("`@16UP='D@ M/3X@R!D871A(#H@:6YT("P@8VAI;&1R96X@.B!8+D-O;7!O7!E('0@/2!#;VUP;W-I M=&4N=`T*("`@("`@("!S=')U8W1UV1A=&$]9#$L8VAI;&1R96X]8S%]*0T*"0D)*$-O;7!O M