Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] mutually referencing compilation units
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-09-19 (03:09)
From: John Max Skaller <skaller@o...>
Subject: Re: [Caml-list] mutually referencing compilation units
Xavier Leroy wrote:

>>Is the fact that two mutually referencing units can't be compiled
>>supposed to be a Good Thing?
> No, it is acknowledged as an unfortunate limitation and an annoyance
> to the programmer.  However, there are deep semantical and
> type-theoretical reasons that make it hard to allow cross-module
> recursion in ML.  This is actually a research area that is still
> largely open.

I'm curious if there is a "lay" explanation of what these restrictions 
are. Felix supports intermodule recursion (with some constraints).
Indeed, there is no explicit construction for sequential module 
definitions (you can do it using nesting).

One of the key distinctions which might make this possible in
Felix is that function declarations:

	fun f(i:int):int { return i; }

do NOT declare values. Thus, the above (which maps semantically
to a C++ class) is quite distinct from

	val g = f;

where g is a function closure
(which maps to C++ object of class f).

The recursion allowed includes type recursion too.

The constraint only applies to open directives
and is related to name lookup, not typing.
Since opening a module may lift a name into the current
scope, there is a constraint on the names of modules
being opened .. since it has to be independent of
the order of opening other modules.

John Max Skaller,
snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia.

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: