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 DF0C3BB9C for ; Thu, 1 Dec 2005 02:06:13 +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 jB116DFu013276 for ; Thu, 1 Dec 2005 02:06:13 +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 CAA25446 for ; Thu, 1 Dec 2005 02:06:12 +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 jB116AZX013269 for ; Thu, 1 Dec 2005 02:06:11 +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 jB1163kQ011926; Thu, 1 Dec 2005 10:06:04 +0900 (JST) Date: Thu, 01 Dec 2005 10:07:19 +0900 (JST) Message-Id: <20051201.100719.07647797.garrigue@math.nagoya-u.ac.jp> To: daniel.buenzli@epfl.ch Cc: caml-list@inria.fr Subject: Re: [Caml-list] How to compile different implementations of the same lib From: Jacques Garrigue In-Reply-To: References: <20051130.211930.102965761.garrigue@math.nagoya-u.ac.jp> <4F70401E-AE91-4E5E-AF67-70FBDCC7C353@epfl.ch> X-Mailer: Mew version 4.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Miltered: at nez-perce with ID 438E4C85.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 438E4C82.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 lib:01 bunzli:01 buenzli:01 epfl:01 bunzli:01 cmx:01 cmi's:01 dependencies:01 inlining:01 cmx:01 inlining:01 lib:01 inlined:01 statically: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: Daniel B=FCnzli > Le 30 nov. 05 =E0 15:38, Daniel B=FCnzli a =E9crit : > = > > Le 30 nov. 05 =E0 13:19, Jacques Garrigue a =E9crit : > > > >> 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 majo= r > >> advantage of native code.) > > > > I don't understand this. Careful to compile what without which cmx = = > > around ? And where do you lose inlining ? > = > Now I think I understand this. You mean when you compile client code = = > client.ml against the library. Then functions from the lib will not = > be inlined in client code. This allows to switch implementations of = > the library without recompiling client.ml. More precisely, if you = > statically link with the lib you only need to relink and if you = > dynamically link you don't even need to do anything, you can just = > play with CAML_LD_LIBRARY_PATH. Right ? Yes, that's the idea. I should have been more specific: In order to create a clean separation between the library and the client, such that you will be able to change the implementation of the library, you must write .mli's for all the modules the library exports, and compile the client with only the .cmi's in the path. Note of course that the .mli/.cmi must also be copied to the directory where you compile the library (the compiler only looks for them there when compiling the .ml). A result is that there cannot be any inlining between client and library. Actually, this is even worse than that: this also prevents direct function calls, as the concrete information about functions is also in the .cmx. All calls will have to go through closures. Just like when you call a function received as parameter, or inside a functor. This suggests the other evident alternative: write the client as a functor. This will not be slower! But this can be more painful if there are several modules in the client... Jacques Garrigue