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 QAA10634; Thu, 22 Nov 2001 16:52:06 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA10411 for caml-list@pauillac.inria.fr; Thu, 22 Nov 2001 16:52:06 +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 FAA28312 for ; Thu, 22 Nov 2001 05:27:27 +0100 (MET) Received: from sj1-3-4-9.iserver.com (sj1-3-4-9.iserver.com [128.121.214.42]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id fAM4RPn12237 for ; Thu, 22 Nov 2001 05:27:26 +0100 (MET) Received: (qmail 40998 invoked by uid 16863); 22 Nov 2001 04:27:24 -0000 Received: from unknown (HELO localhost) ([unknown]) (envelope-sender ) by unknown (qmail-ldap-1.03) with SMTP for ; 22 Nov 2001 04:27:24 -0000 Date: Thu, 22 Nov 2001 04:27:24 +0000 (GMT) From: Brian Rogoff To: William Harold Newman cc: caml-list@inria.fr Subject: Re: [Caml-list] limits on mutual recursion and modules? In-Reply-To: <20011121195339.A24894@rootless> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, 21 Nov 2001, William Harold Newman wrote: > I'm trying to understand the limits on mutual recursion in ML. > > I've seen the hack > type 'a combination = T1 of int | T2 of 'a | T3 of 'a * 'a > class virtual test = > object > method virtual get: test combination > end > for mutual recursion between classes and modules in OCaml. That doesn't You mean between classes and types here, of course. > leave me with much confidence that I can figure out whether a particular > kind of mutual recursion is possible.:-| > > I've seen various statements about recursion between modules being > impossible, but I'm not sure exactly how severe a limitation this is > in practice, especially given the possibility of hacks like the one > above. That hack, which I've seen called the "parameterization trick" (we really need a better, sexier sounding name for it) is the way you currently create a recursion between a type definition and a functor instantiation. > In particular, I'm curious whether it's possible to define > a record type Foo which contains a functor-defined data structure which > refer to objects of type Foo. E.g., in OCaml is there any way > to define a record type Foo one of whose fields is a Set of Foo? You use that same trick. It also means that you must make a polymorphic version of Set to participate in the recursion; the library Set won't do. Check this out http://caml.inria.fr/archives/200010/msg00154.html It's my guess that every frequent user of OCaml or SML bangs into this within their first 9 months of serious ML programming, and most likely long before that. > In general, I'd be interested in any pointers to treatments of this > problem and the theoretical limits involved. http://cristal.inria.fr/~hirschow/index.html as he is the one working on it and he has pointers to related work there. -- Brian ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr