From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id NAA21337; Fri, 22 Feb 2002 13:00:42 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 NAA20835 for ; Fri, 22 Feb 2002 13:00:42 +0100 (MET) Received: from mailb.telia.com (mailb.telia.com [194.22.194.6]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g1MC0fv27797 for ; Fri, 22 Feb 2002 13:00:41 +0100 (MET) Received: from d1o901.telia.com (d1o901.telia.com [62.20.252.241]) by mailb.telia.com (8.11.6/8.11.6) with ESMTP id g1MC0eW24342 for ; Fri, 22 Feb 2002 13:00:40 +0100 (CET) Received: from [62.20.252.83] (t1o901p83.telia.com [62.20.252.83]) by d1o901.telia.com (8.8.8/8.8.8) with ESMTP id NAA03145 for ; Fri, 22 Feb 2002 13:00:38 +0100 (CET) User-Agent: Microsoft-Outlook-Express-Macintosh-Edition/5.02.2022 Date: Fri, 22 Feb 2002 13:06:16 +0100 Subject: [Caml-list] local root registration From: Winfried Dreckmann To: =?ISO-8859-1?B?gA==?= caml list Message-ID: Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Dear Caml-list, Some time ago, Xavier Leroy wrote: > We've been through several designs for the "local root registration" API. > The CAMLxxx macros are the latest design, and the one that we think is > the easiest to use. I agree that they are easiest if one strictly follows the rules in the documentation. However, I would like to point out that there are cases where one does not want to do this. In these cases, the older macros (Begin_roots and End_roots) are much more flexible, and can even lead to better code. I will discuss this a little. Perhaps the Begin_roots/End_roots macros should not be deprecated, but left as a low level alternative? In one case the documentation already differs between a simple and a low level interface, and I believe this is a good approach. What do other list members think? I am thinking of cases, where one uses resizable blocks, which are only occasionally resized, while usually nothing gets allocated. A good example is Michel Quercia's "Numerix". He has resizable big integers, and of course wants to save every cpu cycle for crucial arithmetic operations when allocation does not occur. His approach is to surround the allocators and resizers by Begin_roots/End_roots macros, e. g. #define Enlarge_1_1(a,l,b) { \ if (Capacity(a) < (l)) { \ Begin_roots2(a,b); \ New(a,0,2*(l)+1); \ End_roots2(a,b); \ } \ } (see "lib/common/ml-alloc.h" in the numerix distribution). In this way, the price for garbage collection is only paid if allocation actually takes place. It seems impossible to achieve the same effect with CAMLxxx macros. Winfried Dreckmann ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners