English version
Accueil     Ŕ propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis ŕ jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml ŕ l'adresse ocaml.org.

Browse thread
Best way to choose an implementation of a lib ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-12-02 (03:06)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] How to compile different implementations of the same lib
From: Christophe Raffalli <christophe.raffalli@univ-savoie.fr>
> if I have
> toto.cmi in /usr/lib/ocaml
> toto.cmx and toto.o in /usr/lib/ocaml/totov1/ compiled from totov1.ml
> toto.cmx and toto.o in /usr/lib/ocaml/totov2/ compiled from totov1.ml
> tata.ml that does "open Toto"
> then use either
> ocamlopt -I +totov1 toto.cmx tata.ml
> ocamlopt -I +totov2 toto.cmx tata.ml
> shouldn't this work ?

Of course it will.
You were asking for _link time_ choice.
If it's ok to downgrade to compile time choice, knowing that the
interfaces guarantee that you will be able to recompile with an
alternative library, then this is just the standard ocaml approach.
This is also the reason one doesn't use functors often in ocaml:
implementation choice, with abstraction guarantees, can already be
done by setting some path, which is simpler than parameterizing all
your code.

In your example, it would then be cleaner to put toto.cmi in both totov1
and totov2, since you will need anyway one of the two when compiling.

> Indeed, I tried using "the ln -s" trick for compilation as suggested ...
> and it seems to work ?

It will work, but -I is enough, and seems simpler to me for a library.

Jacques Garrigue