9074Re: Circular dependencies between modules
- Dec 1, 2007Fabrice Marchant <fabrice.marchant@...> writes:
> If two.ml uses several one.ml components, so they appear in this order :If the reference is a function, you can also use this :
> one.ml two.ml in the Makefile, a cheat to access a two.ml component
> inside one.ml would be :
> to define a reference to None inside one.ml,
> to reinitalize this reference, at runtime from two.ml, with Some copy of
> this wanted two.ml component.
> 'option' use causes the things to be heavier but otherwise they would
> become not only ugly but even unsafe.
> But maybe I'm wrong and there is a better way...
let f : (int -> string -> string) ref =
ref(fun _ _ _ -> failwith "not implemented yet")
let f x y z = "do the real stuff"
One.f := f
There is several problem with this:
- you need to explicitly give the type of f in one.ml,
- this type must not be polymorphic.
- this will only work with function.
- << Previous post in topic Next post in topic >>