From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 48C05BB81 for ; Fri, 2 Dec 2005 04:06:15 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jB236Ett032641 for ; Fri, 2 Dec 2005 04:06:14 +0100 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id EAA18125 for ; Fri, 2 Dec 2005 04:06:14 +0100 (MET) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id jB236C6f032247 for ; Fri, 2 Dec 2005 04:06:13 +0100 Received: from localhost (suiren [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.13.1/8.13.1) with ESMTP id jB236961025257; Fri, 2 Dec 2005 12:06:11 +0900 (JST) Date: Fri, 02 Dec 2005 12:06:05 +0900 (JST) Message-Id: <20051202.120605.63743529.garrigue@math.nagoya-u.ac.jp> To: christophe.raffalli@univ-savoie.fr Cc: caml-list@inria.fr Subject: Re: [Caml-list] How to compile different implementations of the same lib From: Jacques Garrigue In-Reply-To: <438F6C0E.6080206@univ-savoie.fr> References: <438F2CE5.9030105@univ-savoie.fr> <1133459647.9266.20.camel@rosella> <438F6C0E.6080206@univ-savoie.fr> X-Mailer: Mew version 4.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 438FBA26.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 438FBA24.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 lib:01 christophe:01 raffalli:01 christophe:01 raffalli:01 univ-savoie:01 cmi:01 usr:01 lib:01 ocaml:01 cmx:01 usr:01 ocaml:01 cmx:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 From: Christophe Raffalli > 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