Version française
Home     About     Download     Resources     Contact us    
Browse thread
Using modules and classes recursively
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Brian Rogoff <bpr@b...>
Subject: Re: Using modules and classes recursively
On Tue, 12 Jan 1999, Xavier Leroy wrote:
> > Is it impossible to have modules and classes combined recursively?
> 
> Currently, yes.  A module definition cannot be mutually recursive with
> any other definition (type, class, or another module).  This raises a
> number of difficult typechecking and compilation problems that are
> still largely open.  I agree this is probably the most irritating
> restriction of ML modules.

A similar restriction also exists in Ada, i.e., two package specifications
cannot "with" (open) each other. One workaround for the case where you
have mutually dependant tagged types (classes) in separate package specs
is to break the cycle by creating a dummy parent type for each of the 
dependant tagged types and using those in place of the type which would 
cause the problem, in this case a "foo_dummy_parent set" would replace foo
in the problem spots, foo would inherit from foo_dummy_parent and the
foos that go into the set would have to be coerced to foo_dummy_parent.

I think this trick will work in OCaml too, but I haven't tried.

-- Brian

PS: For the Ada aware Camlists (Camlers?),

	http://www.bluemarble.net/~jvolan/WithingProblem/FAQ.html

    is a long discussion of the problem in Ada.