Re: Using modules and classes recursively

From: Brian Rogoff (bpr@best.com)
Date: Tue Jan 12 1999 - 19:49:59 MET


Date: Tue, 12 Jan 1999 10:49:59 -0800 (PST)
From: Brian Rogoff <bpr@best.com>
To: Xavier Leroy <Xavier.Leroy@inria.fr>
Subject: Re: Using modules and classes recursively
In-Reply-To: <19990112182919.00681@pauillac.inria.fr>

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.



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:17 MET