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.1 required=5.0 tests=AWL,MAILTO_TO_SPAM_ADDR autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id F0AFABC69 for ; Sun, 5 Aug 2007 17:50:52 +0200 (CEST) Received: from ipmail01.adl2.internode.on.net (ipmail01.adl2.internode.on.net [203.16.214.140]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l75Fool3011625 for ; Sun, 5 Aug 2007 17:50:52 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAPKLtUZ5LGJp/2dsb2JhbAAN X-IronPort-AV: E=Sophos;i="4.19,222,1183300200"; d="scan'208";a="167381680" Received: from ppp121-44-98-105.lns10.syd6.internode.on.net (HELO [192.168.1.201]) ([121.44.98.105]) by ipmail01.adl2.internode.on.net with ESMTP; 06 Aug 2007 01:20:48 +0930 Subject: Re: [Caml-list] try with From: skaller To: tmp123@menta.net Cc: caml-list@yquem.inria.fr In-Reply-To: <46B5ECE4.2050208@menta.net> References: <46B5ECE4.2050208@menta.net> Content-Type: text/plain Date: Mon, 06 Aug 2007 01:50:47 +1000 Message-Id: <1186329047.5975.5.camel@rosella.wigram> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 46B5F1DA.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; 0200,:01 sourceforge:01 wrote:01 exception:01 caml-list:01 exceptions:01 exceptions:01 match:02 match:02 let:03 let:03 tmp:05 john:08 correct:08 felix:09 On Sun, 2007-08-05 at 17:29 +0200, tmp123@menta.net wrote: > Hello, > > Sorry for an easy question about exceptions: > > If in a code like: > > let v1 = f1 () in > f2 v1 > > I like to handle in a different way an exception (like Not_found) > produced inside f1 of the same one produced in f2 (or even not treat the > one produced in f2), which one is a correct way to write the code? Eliminate the exceptions, they're usually a bad idea: let v1 = try Some (f1 ()) with Not_found -> None in let v2 = match v1 with | None -> Error1 | Some x -> try Some (f2 x) with Not_found -> None in match v2 with | None -> Error2 | Some v2 -> ... -- John Skaller Felix, successor to C++: http://felix.sf.net