From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p8FA54ds007406 for ; Thu, 15 Sep 2011 12:05:04 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlYCAIjNcU6GnQCBk2dsb2JhbABChFWUQY43FAEBAQEJCQsJFAMjgVMBAQUjBAsBRREJAhgCAgUWCwICCQMCAQIBRRMGAgKrOpFggSyEN4ERBJNHhRyMEA X-IronPort-AV: E=Sophos;i="4.68,386,1312149600"; d="scan'208";a="109159324" Received: from shiva.jussieu.fr ([134.157.0.129]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 15 Sep 2011 12:04:59 +0200 Received: from hydrogene.pps.jussieu.fr (hydrogene.pps.jussieu.fr [134.157.168.1]) by shiva.jussieu.fr (8.14.4/jtpda-5.4) with ESMTP id p8FA43W3057019 for ; Thu, 15 Sep 2011 12:04:04 +0200 (CEST) X-Ids: 164 Received: from [134.157.168.19] (potassium.pps.jussieu.fr [134.157.168.19]) by hydrogene.pps.jussieu.fr (Postfix) with ESMTP id AA528C3360 for ; Thu, 15 Sep 2011 12:04:40 +0200 (CEST) Message-ID: <4E71CDB8.5020704@dogguy.org> Date: Thu, 15 Sep 2011 12:04:40 +0200 From: Mehdi Dogguy User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.1.16) Gecko/20110506 Iceowl/1.0b1 Icedove/3.0.11 MIME-Version: 1.0 To: caml-list@inria.fr References: <20110913183714.GA15241@yeeloong.happyleptic.org> In-Reply-To: <20110913183714.GA15241@yeeloong.happyleptic.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Miltered: at jchkmail.jussieu.fr with ID 4E71CDB9.002 by Joe's j-chkmail (http : // j-chkmail dot ensmp dot fr)! X-j-chkmail-Enveloppe: 4E71CDB9.002/134.157.168.1/hydrogene.pps.jussieu.fr/hydrogene.pps.jussieu.fr/ Subject: Re: [Caml-list] Lwt and exceptions On 13/09/2011 20:37, rixed@happyleptic.org wrote: > The Lwt doc states that you should not use "raise" when using Lwt but > use Lwt.fail instead. > > So, is it still OK to call functions (for instance from the stdlib) > that may raise an exception, provided we catch it soon enough ? And by > "soon enough" I mean: before an Lwt call that could schedule another > thread. > I guess, not (and it has been answered already). In fact, I was wondering if Lwt's authors would be against adding a function like: let wrap f x = try Lwt.return (f x) with e -> Lwt.fail e It is stupid, trivial, etc… but looks what we need most of the time, no? Instead of doing it in our own code, it could land in Lwt directly. But, if it gets integrated into Lwt proper, users should be warned about its behaviour. (especially with impure functions). Regards, -- Mehdi Dogguy مهدي الدڤي http://dogguy.org/