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 HAA21926 for caml-red; Tue, 24 Oct 2000 07:13:40 +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 RAA14474 for ; Mon, 23 Oct 2000 17:35:55 +0200 (MET DST) Received: from shell5.ba.best.com (shell5.ba.best.com [206.184.139.136]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id e9NFZrv28856; Mon, 23 Oct 2000 17:35:53 +0200 (MET DST) Received: from localhost (bpr@localhost) by shell5.ba.best.com (8.9.3/8.9.2/best.sh) with ESMTP id IAA03993; Mon, 23 Oct 2000 08:35:51 -0700 (PDT) Date: Mon, 23 Oct 2000 08:35:51 -0700 (PDT) From: Brian Rogoff To: Tom Hirschowitz cc: caml-list@inria.fr Subject: Re: circular types? In-Reply-To: <200010230743.e9N7hJv12430@concorde.inria.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: weis@pauillac.inria.fr On Mon, 23 Oct 2000, Tom Hirschowitz wrote: > > Nope, no forwards in Ocaml. At some point, you'll have to tie the recursive > > knot with an "and". If the problem you're having is that "far away" means > > "in different modules" then you bump into the lack of recursive modules, > > IMO the biggest PITA with ML style modules. > > Hi, > > I'm pleased to see I'm not working for nobody. > Actually I'm not working exactly on recursive modules, but rather on > mixin modules. > Instead of defining your two modules and then link them, you would > create a new one with the holes filled. > For instance, for Brain's example, you would write something like : > > mixin A = > mix > deferred module CompositeSet : sig type t ... end > type composite = { data : string ; children : CompositeSet.t } > end;; > > mixin B = > mix > deferred type composite > module CompositeSet = > struct > type t = C of composite | D > end > end > > mixin C = A + B > > In fact, this one is too difficult for me right now, because it > relies on a mutual dependency between a type and a module. I don't mind viewing modules as "the higher level" meaning that if you can have mutually recursive modules this is good enough since I just encapsulate the type in a module. This is going to be a bit unnatural sometimes because the Ocaml implemenation uses the top level module names specially but probably no big deal in practice. This is what Moscow ML does; in OCamlized syntax the composite set looks like this I think module Composite = rec (Fwd : sig module ElemSet sig type t end end) struct module Elem = struct type t = { data : string ; children : Fwd.ElemSet.t } end module ElemSet = struct type t = Elem.t Set.t end end If you can support something similar that's fine with me, but if you think you the direct type and module mutual recursion is workable that's even better. And if you can do that then allowing mutual recursion between classes and types also should be allowed. > Since I'm just beginning this, I would really be pleased by > comments, suggestions or questions about it. I also like that the syntax I show above consumed no more keywords. Just something to think about. -- Brian