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.1 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 9E0A3BB84 for ; Thu, 11 Dec 2008 16:08:10 +0100 (CET) X-IronPort-AV: E=Sophos;i="4.33,753,1220220000"; d="scan'208";a="21128873" Received: from discorde.inria.fr ([192.93.2.38]) by mail1-smtp-roc.national.inria.fr with ESMTP; 11 Dec 2008 16:08:10 +0100 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id mBBF88c8014518 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 11 Dec 2008 16:08:10 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqwCABe8QElQDPIRgmdsb2JhbACTTQEBCwsIBxMDuQ2CeQ X-IronPort-AV: E=Sophos;i="4.33,753,1220220000"; d="scan'208";a="20246187" Received: from smtp19.orange.fr ([80.12.242.17]) by mail3-smtp-sop.national.inria.fr with ESMTP; 11 Dec 2008 16:07:54 +0100 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf1907.orange.fr (SMTP Server) with ESMTP id EBC761C000AB for ; Thu, 11 Dec 2008 16:07:53 +0100 (CET) Received: from [192.168.1.66] (APuteaux-154-1-30-38.w83-199.abo.wanadoo.fr [83.199.85.38]) by mwinf1907.orange.fr (SMTP Server) with ESMTP id CAA331C000A5 for ; Thu, 11 Dec 2008 16:07:53 +0100 (CET) X-ME-UUID: 20081211150753830.CAA331C000A5@mwinf1907.orange.fr Message-ID: <49412CC8.5080902@frisch.fr> Date: Thu, 11 Dec 2008 16:07:52 +0100 From: Alain Frisch User-Agent: Thunderbird 2.0.0.18 (Windows/20081105) MIME-Version: 1.0 To: caml-list@inria.fr Subject: Re: [Caml-list] wrapping external classes References: <8119C403-2D50-4DFA-901C-FC3F8409843E@gmail.com> <20081211103723.GE18977@NANA.localdomain> In-Reply-To: <20081211103723.GE18977@NANA.localdomain> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 49412CD8.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; frisch:01 frisch:01 foo:01 val:01 ocaml:01 finalizer:01 finalizer:01 finalizers:01 wrote:01 integer:01 terminate:01 caml-list:01 alain:01 alain:01 explicitly:02 Mauricio Fernandez wrote: > class foo s n = > object(self) > val handle = create s n > > method compute = compute handle > > initializer > (* use a destroy method explicitly if you need to make sure the destructor > * is called --- Gc.finalise doesn't guarantee this (e.g. the program might > * terminate before the finalisation function is executed) *) > Gc.finalise destroy handle > end If the handle is really an OCaml integer, it is not possible to attach a finalizer to it. The finalizer could be attached to the object that wraps the handle; but the best solution is to use custom blocks and C finalizers in the C binding. -- Alain