From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p19Lp2J5011751 for ; Wed, 9 Feb 2011 22:51:02 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: At8BAF2bUk1KfVIqkGdsb2JhbACXPYEmjG8IFgEBAQkJDAcRBCChUIwjAQWNaQEEhVyUKTo X-IronPort-AV: E=Sophos;i="4.60,447,1291590000"; d="scan'208";a="99595255" Received: from mail-ww0-f42.google.com ([74.125.82.42]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 09 Feb 2011 22:50:57 +0100 Received: by wwi17 with SMTP id 17so2317016wwi.3 for ; Wed, 09 Feb 2011 13:50:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:from:to:cc:references:in-reply-to:subject:date :organization:message-id:mime-version:content-type :content-transfer-encoding:x-mailer:thread-index:content-language; bh=6NsRFT5K+kultYXH+M4dV+rXcdVxfZJOgtXK0/WLQjA=; b=L4Cp6WbjFcGix7uP1sOfYXu90lv4HNlGpBV+OvnJFAPju2SdGR+rv0t1UsoZdzyUk+ IL7/bPKRgoPAxRokQgIca74fdgBBsf0/Z0WpIwCCzC19yy5f4Yk+Z2LS226lRZAM0+Ob JbqPBbX2yaPbnf0xShIjo1uxWJMimoutZ0lzg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=from:to:cc:references:in-reply-to:subject:date:organization :message-id:mime-version:content-type:content-transfer-encoding :x-mailer:thread-index:content-language; b=axZ8LuNAn15Rpvo7pRKEtc1HWsfOqPAq/i2jg67/ndFpl/I//iUUoREWwRazXiGlSe v5G96zAE0gkoy4RlBWstTdt1nE67dqdP1ojiYpUivWHGdC1OkTvyck9+qjO4rJj+fhtq Vd++x8IfXhpbH8AkdquTco3VivbnpsIX7fDnw= Received: by 10.227.143.5 with SMTP id s5mr11543765wbu.82.1297288255960; Wed, 09 Feb 2011 13:50:55 -0800 (PST) Received: from WinEight (231.98.112.87.dyn.plus.net [87.112.98.231]) by mx.google.com with ESMTPS id w25sm668144wbd.11.2011.02.09.13.50.54 (version=SSLv3 cipher=RC4-MD5); Wed, 09 Feb 2011 13:50:54 -0800 (PST) From: Jon Harrop To: Cc: References: <50AF76A1-30E0-4735-AFB2-88BB603899CE@ezabel.com> <77df810e993b3002f8b97622102da8dd.squirrel@mail.mpi-sws.org> <1297268092.24058.416.camel@thinkpad> <25000DA4-042A-437D-8082-10C70E1C740F@ezabel.com> In-Reply-To: <25000DA4-042A-437D-8082-10C70E1C740F@ezabel.com> Date: Wed, 9 Feb 2011 21:50:39 -0000 Organization: Flying Frog Consultancy Message-ID: <047101cbc8a3$653f1ad0$2fbd5070$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AcvIgmszSUWYwjuQRnepNxCDLmTk5QAIJAcg Content-Language: en-gb Subject: RE: [Caml-list] Scoped Bound Resource Management just for C++? Orbitz: > Do they appear in C++? Yes. > I would a dtor takes care of that for you when it comes to streams. Only when the dtor is called. If a thread is aborted or exit or abort are called then the dtor may not be called and your resource may leak. > How does one safely write code in Ocaml that guarantees resources will be freed? You cannot so you make the best of a bad job and write code that catches most errors in practice, like the code I gave. You might also add a syntactic construct like F#'s "use" binding that makes this even simpler and clearer but, ultimately, it is still not perfect. Cheers, Jon.