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.2 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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 896E7BC6C for ; Thu, 31 Jan 2008 21:26:01 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAB6+oUfAXQImh2dsb2JhbACQIgEBAQgKKZ96 X-IronPort-AV: E=Sophos;i="4.25,287,1199660400"; d="scan'208";a="22031420" Received: from discorde.inria.fr ([192.93.2.38]) by mail4-smtp-sop.national.inria.fr with ESMTP; 31 Jan 2008 21:26:01 +0100 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m0VKQ0e6017268 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 31 Jan 2008 21:26:00 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAB6+oUfBMVMPeWdsb2JhbACQIgEBCQQGBiOfeg X-IronPort-AV: E=Sophos;i="4.25,287,1199660400"; d="scan'208";a="22031416" Received: from kabis.univ-orleans.fr (HELO ka.univ-orleans.fr) ([193.49.83.15]) by mail4-smtp-sop.national.inria.fr with ESMTP; 31 Jan 2008 21:25:44 +0100 Received: from smtps.univ-orleans.fr (localhost [127.0.0.1]) by ka.univ-orleans.fr (Postfix) with ESMTP id AA1CA12AE66; Thu, 31 Jan 2008 21:25:43 +0100 (CET) Received: from [192.168.0.1] (lau18-1-82-246-197-195.fbx.proxad.net [82.246.197.195]) by smtps.univ-orleans.fr (Postfix) with ESMTP id 4571436E5B; Thu, 31 Jan 2008 21:25:47 +0100 (CET) Subject: Re: [Caml-list] [OSR] Exceptionless error management From: David Teller To: =?ISO-8859-1?Q?B=FCnzli?= Daniel Cc: Andrej.Bauer@andrej.com, caml-list List In-Reply-To: References: <9d3ec8300801310157r77b86fc0k80f40b1df36091c2@mail.gmail.com> <0640C30E-07B5-4885-AC38-671755BB79AA@erratique.ch> <47A1D68B.70700@fmf.uni-lj.si> Content-Type: text/plain; charset=utf-8 Date: Thu, 31 Jan 2008 21:25:41 +0100 Message-Id: <1201811141.6565.21.camel@Blefuscu> Mime-Version: 1.0 X-Mailer: Evolution 2.12.1 Content-Transfer-Encoding: 8bit X-Miltered: at discorde with ID 47A22ED8.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; univ-orleans:01 0100,:01 andrej:01 recursive:01 trivial:01 camlp:01 cheers:01 univ-orleans:01 lifo:01 liquidations:98 wrote:01 caml-list:01 functions:01 exceptions:01 tail:01 On Thu, 2008-01-31 at 21:03 +0100, Bünzli Daniel wrote: > Le 31 janv. 08 à 15:09, Andrej Bauer a écrit : > > > I have become to prefer option types as return values (as opposed to > > exceptions), but I admit it can be annoying to always consider both > > possibilities, especially if you know that "None" won't happen. > > Maybe it is a point of view, you are fed up of considering both > possibilites while I'm personally fed up of writing > > match try Some (f x) with e -> None with > | None -> .. > | Some v -> ... > > Because I need tail recursive functions. What about a generic type result 'r 'e = | Success of 'r (**The operation was a success*) | Failure of 'e (**The operation was a failure*) let purify e = try Success ( Lazy.force e ) with exc -> Failure exc ? With one such mechanism we can nearly automatically transform exception-returning expressions into exceptionless management. We could complete this with a trivial amount of Camlp4 code to avoid the call to "lazy / Lazy.force". What do you think about this solution ? Cheers, David -- David Teller Security of Distributed Systems http://www.univ-orleans.fr/lifo/Members/David.Teller Angry researcher: French Universities need reforms, but the LRU act brings liquidations.