Browse thread
Best way to choose an implementation of a lib ?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2005-11-30 (12:19) |
From: | Jacques Garrigue <garrigue@m...> |
Subject: | Re: [Caml-list] Best way to choose an implementation of a lib ? |
From: Christophe Raffalli <christophe.raffalli@univ-savoie.fr> > Let say I want two distribute two(or more) implementations of a library > with the .mli for all ... > > Is there a way to choose the implementation at link time ? > > Lets say I have a.mli compiled to a.cmi and a1.ml and a2.ml > > I think (did not test) that putting the cmos in separate directory as > a1/a.cmo and a2/a.cmo should allow the choice using the -I option ... > > Any better solution (no dynlink, I want also native code) ? Directories seem a possible solution. Note that with native code you must be careful to compile without any .cmx around (only .cmi's), as this would induce dependencies on a specific version. This also means that you lose inlining (one major advantage of native code.) An alternative to distinct directories is to create libraries (.cma/.cmxa). You could name them a1.cma and a2.cma, and link choosing either one. Libraries are only used at link time, so their names are not hard-coded. This solution has exactly the same pitfalls with native code. Note that ocaml itself does something similar for vmthreads. Distinct libraries for stdlib.cma and unix.cma are installed in a distinct directory, but the .cmi's are not duplicated. This library is bytecode only. Jacques Garrigue