[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Caml-list] managing ocaml dependencies

From: skaller
Subject: Re: [Caml-list] managing ocaml dependencies
Date: Fri, 17 Nov 2006 11:36:15 +1100

On Thu, 2006-11-16 at 22:43 +0100, Nicolas Pouillard wrote:
> On 11/16/06, skaller <address@hidden> wrote:

> When order of initialization matters, just enforce it.

> > For example:
> >
> > (* file 1 *)
> > let a : int opt = ref None
> > ;;
> >
> > (* file 2 *)
> > let _ = a := Some 99
> > ;;
> >
> > (* file 3 *)
> Just add something like:
> open File2;; (* because initialization order matters *)

Really there should be a directive such as:

require File2;;

or something, implied by 'open', and *mandatory* so that


without a 

require/open List;;

was an error. In any case, using make for this kind of
job is a real negative for Ocaml. Felix compiles
dependencies recursively and conditionally. It makes
using it -- and upgrading it -- a breeze, and eliminates
the need for external tool support.

Hmm. It would be interesting to write a driver harness
that did this. The biggest impediment is the lack of
an enforced 'require' directive, and the existence
of Ocamlp4, both of which make it hard to use simple
analysis tools to calculate dependencies.

BTW: in the Felix compiler itself the initialisation
order problem arises with the 'version' record:
whenever any code changes, the time stamp in the
version record is updated. The version record
is first in the link order, so any part of the code
can refer to it .. but the actual time stamp is
last in link order to avoid gratuitous recompilations.
Its module uses the above trick -- the time stamp
is stored into the version record by executable 
initialisation code dynamically before any
functions are called in the mainline. This implies
that no modules refer to the version record dynamically in 
initialisations (except the mainline).

This is nasty because this version record is
Marshalled out into pre-compiled Felix code,
and is actually then used for the dependency
checking in Felix -- if the compiler version
changes the Felix sources need to be recompiled.

So there is a 'exponential' dependency situation, where
getting the order right is critical,
hard to enforce, and hard to detect when there
is an error.

Skallers Law: if a programmer can make a mistake ..
skaller will make it.

John Skaller <skaller at users dot sf dot net>
Felix, successor to C++:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]