--- In ocaml_beginners%40yahoogroups.com">ocaml_beginners
yahoogroups.com, Jon Harrop <jon
...> wrote:
> Which is the correct or desired solution? You can't know, and neither can the
> compiler but ocamldep can guess (and get it wrong).
Of course you know what your program should do or print ! There
are two kinds of order constraints for compilation : those that the user
must provide explicitly to the compiler (as in your example) and
those that can be deduced automatically by ocamldep by scanning the files. My
point was that there is no reason to force the user to worry
about the latter. In an imaginary world,
the command dealing with your example would be
ocamlc -a -additional_constraints "please compile a before b !"
-o my_library.cma x.cmo b.cmo y.cmo z.cmo a.cmo
(or "please compile b before a!", depending on what you want your program to do).
> Which of the two possible solutions above is the "unique arbitrary" solution?
In mathematical terms, the idea is this : there is a partial ordering
(the initial "dependency constraints") on the
set of all the files to be compiled, and you must extend it to a total ordering.
The algorithm is to take a f1 that does not depend on any other module,
then a f2 in the remaining that does not depend on anything but f1, etc.
(if you insist on uniqueness, take f1 to be "minimal" among the independent
modules with respect to file creation date, lexicographic order on filenames, or your
favorite total order).
Ewan
.