Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Modules Order
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Warp <warplayer@f...>
Subject: [Caml-list] Modules Order
Hi all,

In my last post, I was talking about finding the good order for CMO-linking
when you only got ocamldep output.
I've think about it, and here's some results, please let me know if there is
another/better way.

First of all, the main problem is CMOs have to be linked in the "right"
order, so, if A is calling a function into B, B.cmo has to be passed before
A.cmo in ocamlc arguments.

When you got the following :

A.cmo : A.cmi B.cmi
B.cmo : B.cmi A.cmi

You can't really choose which one of A or B is the first, that's where there
is a "cross".
Now if you have

A.cmi : B.cmi

Then you can say that maybe some function of A is using a type of B. So if
the user doesn't make real cross calls, then you can put A before B
 because B is perhaps calling A )

And if you have both :

A.cmi : B.cmi
B.cmi : A.cmi

Then that's an user design issue :)
Now , let's back to the first sample ( without any dependency between
CMIs ).
If A and B are not then only modules, than there is a way to "guess" the
order.

- First you got your depency tree, composed of ML & MLI files. You need to
add an ML -> ML link when you got a dependency ML -> MLI . If you omit
"supposed crossing" modules ( A & B ) then you're not making any cycle in
you dependency tree.

- Now you try to add the link A.ml -> B.ml , and if that link create a
cycle, then you can say that there is already a way to reach A from B, so
you can guess/hope that the user have a valid design so you have to put
A.cmo before B.cmo and then the conflict is resolved

- if none of the A.ml -> B.ml & B.ml -> A.ml links create a cycle, then you
can't say anything.... ( flip a coin, so linking should work at least 50% of
the time :)

Now I would like to generalize this algorithm with N-crossing-modules. If
anyone got some idea...

Nicolas Cannasse


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners