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 concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 18F5EBB9C for ; Wed, 30 Nov 2005 13:19:41 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id jAUCJebV014900 for ; Wed, 30 Nov 2005 13:19:40 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id NAA05429 for ; Wed, 30 Nov 2005 13:19:39 +0100 (MET) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jAUCJaBt024937 for ; Wed, 30 Nov 2005 13:19:38 +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 jAUCJYJ1022893; Wed, 30 Nov 2005 21:19:35 +0900 (JST) Date: Wed, 30 Nov 2005 21:19:30 +0900 (JST) Message-Id: <20051130.211930.102965761.garrigue@math.nagoya-u.ac.jp> To: christophe.raffalli@univ-savoie.fr Cc: caml-list@inria.fr Subject: Re: [Caml-list] Best way to choose an implementation of a lib ? From: Jacques Garrigue In-Reply-To: <438D6B4D.1070004@univ-savoie.fr> References: <438D6B4D.1070004@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 concorde with ID 438D98DC.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 438D98D9.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 mli:01 mli:01 cmi:01 cmo:01 cmo:01 dynlink:01 cmx:01 cmi's: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 > 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