From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id NAA00540; Mon, 18 Mar 2002 13:19:46 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 NAA00530 for ; Mon, 18 Mar 2002 13:19:45 +0100 (MET) Received: from avocet.prod.itd.earthlink.net (avocet.mail.pas.earthlink.net [207.217.120.50]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g2ICJiH13237 for ; Mon, 18 Mar 2002 13:19:44 +0100 (MET) Received: from user-0ccegg9.cable.mindspring.com ([24.199.66.9] helo=flapdragon.homeip.net) by avocet.prod.itd.earthlink.net with esmtp (Exim 3.33 #1) id 16mw74-0000my-00; Mon, 18 Mar 2002 04:19:42 -0800 Subject: Re: [Caml-list] Functorizing large collections of modules From: "Yaron M. Minsky" To: Remi VANICAT Cc: caml-list@inria.fr In-Reply-To: <87vgbu2qsd.dlv@wanadoo.fr> References: <1016424584.26193.42.camel@dragonfly.localdomain> <87vgbu2qsd.dlv@wanadoo.fr> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Mailer: Evolution/1.0.2 Date: 18 Mar 2002 07:19:41 -0500 Message-Id: <1016453982.27588.53.camel@dragonfly.localdomain> Mime-Version: 1.0 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk The problem, I think, with the solution listed below is that I don't see how Bar can refer to Foo easily. In particular, it seems like every time Foo.Make(ZZp) references Bar, it really needs to refrence Bar.Make(ZZp). And come to think of it, I don't know how to do this at all, since (I think) every invocation of Bar.Make(ZZp) creates an independent instance of the module. =20 In particular, imagine Foo needs to reference Bar. Without functors, the files might look something like this: foo.ml: =20 let _ =3D Bar.snoo (ZZp.snip ()) =20 bar.ml: =20 let open =3D ZZp.bark () + ZZp.flip () =20 Now, with functors, how would this work? =20 foo.ml: =20 module M(ZZp:ZZpSig) =3D=20 struct=20 module Bar =3D Bar.M(ZZp) let _ =3D Bar.snoo (ZZp.snip ()) end =20 bar.ml: =20 module M(ZZp:ZZpSig) =3D=20 struct let open =3D ZZp.bark () + ZZp.flip () end So now foo can refrence bar. But if there's a different module that wants to look at bar also, it will end up referencing a different instance of Bar.M(ZZp), which seems problematic. So now I'm more confused than ever. y On Mon, 2002-03-18 at 04:01, Remi VANICAT wrote: > "Yaron M. Minsky" writes: >=20 > > This seems messy and kind of silly. Conceptually what I want is a > > single structure like this: > >=20 > > module Library(ZZp:ZZpSig) =3D=20 > > struct > >=20 > > module Foo =3D=20 > > struct ... end > >=20 > > module Bar =3D > > struct ... end > > =20 > > ... > >=20 > > end > >=20 > > That way, all the interior modules (Foo, Bar) get to reference the same > > ZZp, without having to functorize the individual modules. So, what I'd > > like is to be able to do this without sticking the modules Foo and Bar > > into the same single large unmanageable file. >=20 > you can call the functor in a bigger functor : >=20 > file foo.ml >=20 > module Make(ZZp:ZZpSig) =3D > struct ... end >=20 > file bar.ml >=20 > module Make(ZZp:ZZpSig) =3D > struct ... end >=20 > file library.ml >=20 > module Make(ZZp:ZZpSig)=3D > struct > module Foo =3D Foo.Make(ZZp) > module Bar =3D Bar.Make(ZZp) > end > --=20 > R=E9mi Vanicat > vanicat@labri.u-bordeaux.fr > http://dept-info.labri.u-bordeaux.fr/~vanicat > ------------------- > To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inr= ia.fr > Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr= /FAQ/ > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners >=20 --=20 |--------/ Yaron M. Minsky \--------| |--------\ http://www.cs.cornell.edu/home/yminsky/ /--------| Open PGP --- KeyID B1FFD916 (new key as of Dec 4th) Fingerprint: 5BF6 83E1 0CE3 1043 95D8 F8D5 9F12 B3A9 B1FF D916 ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners