--- In ocaml_beginners%40yahoogroups.com">ocaml_beginners
yahoogroups.com, Jon Harrop <jon
...> wrote:
>
> On Wednesday 28 February 2007 04:50, roparzhhemon wrote:
> > 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).
>
> Exactly. And the way we confer "please compile b before a!" to the compiler is
> by writing:
>
> ocaml b.ml a.ml -o barfoo
>
I'll try to make my point clearer by comparing ocamlc to my
(admittedly imaginary) extension on a larger example, because
your example is too small to show the difference.
Think of a huge OCaml project with tenths of implementation files
and a complicated dependency tree, with only one non-ocamldep-detectable
dependency :
file a.ml : printf("this should be printed first")
file b.ml : printf("this should be printed second")
Say that one entry in the makefile is ocamlc -a $ALL_THE_FILES -o my_library.cma
Now compare : with ordinary ocamlc you have to be very careful to define
ALL_THE_FILES in the correct order. With my extension you would just write
"ALL_THE_FILES=$(wildcard *.cmo)" and
"ocamlc -additional_constraint "please compile a before b!" -a $ALL_THE_FILES -o
my_library.cma".
Hence a shorter makefile, and less time spent to analyze the dependency tree
(this is especially true when there is no really "natural" module for a global constant
or other data to be defined in, but a choice of equally reasonable modules,
and you can't easily remember in which one you put it).
By the way, if my extension is imaginary for OCaml, it is not for C++. In C++
it is okay to put ALL_THE_FILES=$(wildcard *.cpp) and not bother about the order.
This is what led me to make that remark in the first place.
Perhaps you disagree with me because you write OCaml projects with lots
of ocamldep-undetectable-dependencies (in that case, indeed, my extension
is not very useful). On the other hand, all the OCaml code I've produced
so far does not contain even a single ocamldep-undetectable-dependency.
Regards,
Ewan
.