From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id D8D947EEF8 for ; Tue, 11 Aug 2015 11:36:27 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of goswin-v-b@web.de) identity=pra; client-ip=212.227.17.12; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="goswin-v-b@web.de"; x-sender="goswin-v-b@web.de"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of goswin-v-b@web.de designates 212.227.17.12 as permitted sender) identity=mailfrom; client-ip=212.227.17.12; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="goswin-v-b@web.de"; x-sender="goswin-v-b@web.de"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mout.web.de) identity=helo; client-ip=212.227.17.12; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="goswin-v-b@web.de"; x-sender="postmaster@mout.web.de"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0A9AQCUwclVnAwR49RdhFjFXQKBNkwBAQEBAQESAQEBAQEGDQkJIS6EJAEBBCcTPxALDgoJJQ8FDRshE4gYAQMWyHQfKw2FRgEBAQEGAQEBAR6LUYJPgjoHgxiBFAEElRCKfoFpiFoMiXSHM4QmbwGCSwEBAQ X-IPAS-Result: A0A9AQCUwclVnAwR49RdhFjFXQKBNkwBAQEBAQESAQEBAQEGDQkJIS6EJAEBBCcTPxALDgoJJQ8FDRshE4gYAQMWyHQfKw2FRgEBAQEGAQEBAR6LUYJPgjoHgxiBFAEElRCKfoFpiFoMiXSHM4QmbwGCSwEBAQ X-IronPort-AV: E=Sophos;i="5.15,652,1432591200"; d="scan'208";a="173268698" Received: from mout.web.de ([212.227.17.12]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 11 Aug 2015 11:36:27 +0200 Received: from frosties.localnet ([95.208.221.151]) by smtp.web.de (mrweb102) with ESMTPSA (Nemesis) id 0M2dg1-1YYvKp1SUP-00sNV0; Tue, 11 Aug 2015 11:36:26 +0200 Received: from mrvn by frosties.localnet with local (Exim 4.84) (envelope-from ) id 1ZP5yr-0001cZ-FI; Tue, 11 Aug 2015 11:36:25 +0200 Date: Tue, 11 Aug 2015 11:36:25 +0200 From: Goswin von Brederlow To: Malcolm Matalka Cc: Nicolas Ojeda Bar , caml-list@inria.fr Message-ID: <20150811093625.GA5949@frosties> References: <20150806094030.GE16477@frosties> <864mkcci29.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <864mkcci29.fsf@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Provags-ID: V03:K0:v97CzRKp1ymCK7X6kMAyMoH7SfKCZXQHlV9Kqr9aonex5AnQ2xP tJQcKbPgrW724pjkXGpl2+x5VjeU0RtZCBYtrEsBmwUObckd57RvJHulf1zv4XJkFNrlIci pJvIYXlAkwcWDmfM0bHLd4zJmfUW44ImYsx6pZDJycRxGI+bb/k2K5FYKuKLLpBqpnJH/xz AhrGTUe1tRZCZKrMfnxZQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:bBkOdsXp6p8=:eb5WysHtiYRNaZ+p2bEZLS lVqx1FP8Qikna7WgE3AScuty+lJfjPqImixBXH5AV595Y8mnNM2HWsYjz7aZxJlPZzGJHdxEC 1sc+ekUQNWP5n9UbROkiq96rZ2QdMjSgksHGDgXq+hFwxqNypZ9MtVaZeHWJH+Zj8AdDfJS0m 8yveUpihxgMFwVIk+iBSPjHa14DjdzxyIf8hVZBV04XPlBvH1IYgujblJxMc537eTDmuNrrUd XGNnp2THL04+USuYDR08xptKiQdAsyTZaJZEWIxEXl3cEThQahK8Jj3mjEiwue6Ui16GHtqxo heyfDvCY/oaPPX9mAgGf1vIa/sJ+HXsDLcj9Pu3RV0yoJmdgMsjG8ufEH/3e3oCg8srEuXd1P /li6xbKzHZfMmpxIKpy3eU1bKLjRgbWQUY1sn5LJSA3tv5uW+PtEMJjNkv8/dyNgDjn48/01h z6vevs60sDvDZ/7gtLZabpzSXPFGZ8MJT4M3FGyC9zzcHucW6FokPV24L1W0JucBZ6Akn41Rq 39uN2elcDqEsktVV3QVRpueUxLSGFjj0yfu/WjRWREP8qi9FFHsmwzBwGFDUE4PrcRuYbjII1 yAMcV4umzsiiewt9irMDNzWNs271Xae4+nFA6v30hZim/ti2YJCuYOvuzLp3jXkdtMfbrXF18 hAnj7cFn6nbYkpA9dzkxXMpjf7F7bOHz7ALjhv8lZBN43qLUmYWdd1u51M8cUQestEaUwWX9g EAQ4AeQadeqnYQpc Subject: Re: [Caml-list] Destructive use of file descriptors On Thu, Aug 06, 2015 at 07:50:38PM +0000, Malcolm Matalka wrote: > Nicolas Ojeda Bar writes: > > > Hi, > > > > No magic needed in OCaml: > > > > let with_open path f = > > let oc = open_out path in > > match f oc with > > | x -> close_out_noerr oc; x > > | exception e -> close_out_noerr oc; raise e > > > > and then use it as > > > > with_open "foo" (fun oc -> output_string oc str) > > > > Cheers > > > > Nicolas > > > > The weakness with this (which I'm not sure if Python offers protection) > is returning something that references the file created. It can lead to > some confusing error messages. Yeah. I was thinking that that might be avoided. Something on the line of putting the file descriptor into a local module so ocaml would complain about it escaping its scope or something. At least unlike the other suggestion this one closes the FD on exception. MfG Goswin