From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE autolearn=disabled version=3.1.3 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id BF5A0BC6B for ; Fri, 25 Jan 2008 03:31:32 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAP3YmEeFBoIFh2dsb2JhbACQJAEBAQgKKZ5P X-IronPort-AV: E=Sophos;i="4.25,247,1199660400"; d="scan'208";a="21776134" Received: from discorde.inria.fr ([192.93.2.38]) by mail4-smtp-sop.national.inria.fr with ESMTP; 25 Jan 2008 03:31:32 +0100 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m0P2VNtI026303 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Fri, 25 Jan 2008 03:31:32 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAP3YmEeFBoIFh2dsb2JhbACQJAEBAQgKKZ5P X-IronPort-AV: E=Sophos;i="4.25,247,1199660400"; d="scan'208";a="21776129" Received: from rabbit.math.nagoya-u.ac.jp ([133.6.130.5]) by mail4-smtp-sop.national.inria.fr with ESMTP; 25 Jan 2008 03:31:22 +0100 Received: from localhost (millas [172.16.30.29]) by rabbit.math.nagoya-u.ac.jp (8.12.11/3.7W) with ESMTP id m0P2VD6w000534; Fri, 25 Jan 2008 11:31:13 +0900 (JST) Date: Fri, 25 Jan 2008 11:31:13 +0900 (JST) Message-Id: <20080125.113113.104032782.garrigue@math.nagoya-u.ac.jp> To: jon@ffconsultancy.com Cc: caml-list@inria.fr Subject: Re: [Caml-list] Working around the brittle bindings problem From: Jacques Garrigue In-Reply-To: <200801242140.06785.jon@ffconsultancy.com> References: <200801242140.06785.jon@ffconsultancy.com> X-Mailer: Mew version 4.0.69 on Emacs 22.0.50 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 479949FB.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; bindings:01 bindings:01 ocaml:01 compiler:01 functor:01 functor:01 lablgl:01 ocaml:01 compiler:01 cmi:01 parameterize:01 caml-list:01 functions:01 functions:01 modules:02 From: Jon Harrop > Just occurred to me that one possible solution to our brittle > bindings problem might be to parameterize the whole library over the > external calls that are made. That could at least make the compiled > code dependent only upon the version of the OCaml compiler itself > and not each separate library. > > Is it possible to do this using a functor? I might have to wrap the > entire library in one giant functor but that would let the user > apply the functor to a suitable library module in order to obtain a > working implementation. Am I right in thinking that the result would > depend only upon my interface and no upon the library itself > (e.g. LablGL)? This looks like a good idea. This way you can choose the set of functions you depend upon. This means essentially copying and trimming down mlis. Then you just need to provide the source code for the linking bits, that is a big functor application. This would protect you from checksums changing due to the addition of new functions, or from compatible changes in function types (i.e., types are equal according to ocaml expansion rules). This will not protect you from a real change in function type at the interface (like the addition of a new tag in a type, or of an extra optional argument), or from a change in the compiler itself. If you want maximal protection, you should apply the same approach to standard library modules too, so that compiler changes that do not alter the .cmi format would be allowed, but this is going to be painful. There may also be a performance hit as the function calls get a bit more costly (this should only matter for really fast functions, not for openGL calls). Jacques Garrigue