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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id BD41FBC37 for ; Wed, 10 Feb 2010 09:55:15 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArwBAPYCckvZSMDdkGdsb2JhbACaZxUBAQEBCQkMBxMDILxMhFUE X-IronPort-AV: E=Sophos;i="4.49,442,1262559600"; d="scan'208";a="44423600" Received: from fmmailgate01.web.de ([217.72.192.221]) by mail3-smtp-sop.national.inria.fr with ESMTP; 10 Feb 2010 09:55:15 +0100 Received: from smtp06.web.de (fmsmtp06.dlan.cinetic.de [172.20.5.172]) by fmmailgate01.web.de (Postfix) with ESMTP id B3ABE1468BDEE; Wed, 10 Feb 2010 09:55:14 +0100 (CET) Received: from [95.208.117.111] (helo=frosties.localdomain) by smtp06.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #314) id 1Nf8Lq-0005jv-00; Wed, 10 Feb 2010 09:55:14 +0100 Received: from mrvn by frosties.localdomain with local (Exim 4.71) (envelope-from ) id 1Nf8Lq-0003Oc-5w; Wed, 10 Feb 2010 09:55:14 +0100 From: Goswin von Brederlow To: Rich Neswold Cc: Tiphaine Turpin , caml-list@inria.fr Subject: Re: [Caml-list] Preventing values from escaping a context References: <14cf844b1002081907y2900c313q97ae0cb6f4c92394@mail.gmail.com> <20100209.123813.39168535.garrigue@math.nagoya-u.ac.jp> <4B711D44.7040509@irisa.fr> <14cf844b1002091009p1a3181j793c2d6b2cdcbae5@mail.gmail.com> <4B71AD39.8020503@irisa.fr> <14cf844b1002091639q5641977evc2101f72c80bd10d@mail.gmail.com> Date: Wed, 10 Feb 2010 09:55:14 +0100 In-Reply-To: <14cf844b1002091639q5641977evc2101f72c80bd10d@mail.gmail.com> (Rich Neswold's message of "Tue, 9 Feb 2010 18:39:14 -0600") Message-ID: <871vgto4gd.fsf@frosties.localdomain> User-Agent: Gnus/5.110009 (No Gnus v0.9) XEmacs/21.4.22 (linux, no MULE) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: goswin-v-b@web.de X-Sender: goswin-v-b@web.de X-Provags-ID: V01U2FsdGVkX19OmJIOZAZ0Nqwgf3O7CQXPVEg4mF8SavE6EL5X E0S3d3PKnwcsnbbhvnP9hHumOIJInG4JDAPyw4kobWRCBth604 jHLc5Sfbs= X-Spam: no; 0.00; irisa:01 finalizer:01 finalizer:01 escapes:01 lesson:98 mfg:98 wrote:01 caml-list:01 writes:01 api:02 adaptation:04 drawback:04 reachable:05 tue:06 context:06 Rich Neswold writes: > On Tue, Feb 9, 2010 at 12:45 PM, Tiphaine Turpin > wrote: > > Here is an adaptation of your example. > > > Thank you! I'll experiment with your example to see if I can use it (like you > said, it may be too complicated to add to the API.) Regardless, it was an > interesting lesson and taught me a little more about the language. > > Thanks again, Why not make the context a custom block with finalizer? The finalizer then frees the resources. If the context escapes then it remains alive and the finalizer will not be called any time soon. Only when it is no longer reachable. That would also allow someone to create a context and use it for a number of operations before forgeting it. The drawback is that the finalizer will only be called when the GC runs at some later time. If you need the resources to be freed right there then it won't help. MfG Goswin