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

- 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 -> , 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 -> & -> 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 Archives:
Bug reports: FAQ:
Beginner's list: