* recmod
@ 2004-12-30 22:38 Anastasia Gornostaeva
2004-12-31 1:10 ` [Caml-list] recmod skaller
0 siblings, 1 reply; 2+ messages in thread
From: Anastasia Gornostaeva @ 2004-12-30 22:38 UTC (permalink / raw)
To: caml-list
Hello, Happy New Year!
Is it possible to compile such files?
mod1.ml:
let get a =
if Mod2.mem a then 1 else 2
mod2.ml:
let mem a = List.mem a [1;2;3]
let other () =
print_int (Mod1.get 5)
ermine
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Caml-list] recmod
2004-12-30 22:38 recmod Anastasia Gornostaeva
@ 2004-12-31 1:10 ` skaller
0 siblings, 0 replies; 2+ messages in thread
From: skaller @ 2004-12-31 1:10 UTC (permalink / raw)
To: Anastasia Gornostaeva; +Cc: caml-list
On Fri, 2004-12-31 at 09:38, Anastasia Gornostaeva wrote:
> Is it possible to compile such files?
>
> mod1.ml:
> let get a =
> if Mod2.mem a then 1 else 2
>
> mod2.ml:
> let mem a = List.mem a [1;2;3]
> let other () =
> print_int (Mod1.get 5)
>
No. There is a new experimental feature which provides
some support for intra-module recursion,
but at present the modules must reside
in the same file.
The two common workaround for functions are:
(a) pass Mod2.get to Mod1.get as an argument
(b) create a reference in mod1.ml initialised to
fun (x:int) -> raise Not_found; 1
and in mod2.ml store Mod2.get into it, call it in mod1.ml
by first dereferencing it.
Another technique is to use classes, which automate
the late binding more safely.
--
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850,
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-12-31 1:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-30 22:38 recmod Anastasia Gornostaeva
2004-12-31 1:10 ` [Caml-list] recmod skaller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox