From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA05320 for caml-redistribution; Wed, 10 Feb 1999 17:00:30 +0100 (MET) 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 QAA26448 for ; Wed, 10 Feb 1999 16:27:48 +0100 (MET) Received: from cerberus.ibmoto.com (cerberus.ibmoto.com [129.38.252.34]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id QAA02186 for ; Wed, 10 Feb 1999 16:27:46 +0100 (MET) Received: from ibmoto.com (amartin@canada.ibmoto.com [129.38.151.28]) by cerberus.ibmoto.com (8.9.0/8.9.0) with ESMTP id JAA00881 for ; Wed, 10 Feb 1999 09:27:40 -0600 (CST) Sender: weis Message-ID: <36C1A56B.3C6061B8@ibmoto.com> Date: Wed, 10 Feb 1999 09:27:39 -0600 From: Andrew Martin Organization: Motorola Somerset PowerPC Design Center X-Mailer: Mozilla 4.04 [en] (X11; I; AIX 4.1) MIME-Version: 1.0 To: caml-list@inria.fr Subject: "C" Finalizers Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Are there any restrictions on the things that a finalizer (the first element of a block tagged with Final_tag) can do safely? For instance, can it allocate memory from the Ocaml heap? Can it use callback to apply a closure to a value? Is there any interest in exploring the posibility of introducing a general-purpose finalization mechanism into the Ocaml language itself ? Why do I ask? The reason is probably more academic than practical. I have become curious about whether it is practical to write a BDD package in Ocaml. Agreed, one would loose some efficiency over a "C" implementation. But more critical to BDD performance than the constants involved in accessing BDDs are the heuristics used for variable ordering etc. It may be that a clear ocaml-style presentation is more amenable to experimentation with reordering techniques and heuristics than a necessarily complex "C" implementation. If so, this might ultimately lead to a better performing package which could always be re-implemented (at least partially) in "C" if you wanted to shave some time of the constants. Unfortunately, to track the improvement gained by re-ordering, you really need to be able to know whether a node is referenced by the outside world. While one could concoct various schemes involving arrays of weak pointers to accomplish this, they all feel complicated and contrived -- they very thing I was trying to avoid by writing in Ocaml in the first place. The most natural way do deal with the problem is to define a finalizer that recursively decrements ref counts. Obviously, providing a general finalization mechanism in the Ocaml language itself would be fraught with difficulty e.g. what's to prevent the finalizer from creating new references to the object (and hence indirectly to its descendants) that we just decided to free ? Still, I thought I'd raise the issue and see if anyone is thinking about it. Regards, Andy Martin -- Andrew K. Martin, Ph.D. Motorola Inc., Somerset Design Center Networking and Computer Systems Group phone: (512) 424-8325 6200 Bridgepoint Parkway, Building 4, fax : (512) 424-8846 Mail Drop OE70 email: amartin@ibmoto.com Austin, TX 78730