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.0 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 discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 817C8BC0B for ; Tue, 16 Jan 2007 20:43:42 +0100 (CET) Received: from pih-relay06.plus.net (pih-relay06.plus.net [212.159.14.133]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l0GJhfsZ007246 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Tue, 16 Jan 2007 20:43:42 +0100 Received: from [80.229.56.224] (helo=[10.0.0.5]) by pih-relay06.plus.net with esmtp (Exim) id 1H6uDd-0008NA-Cf for caml-list@yquem.inria.fr; Tue, 16 Jan 2007 19:43:41 +0000 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Ocaml compiler features Date: Tue, 16 Jan 2007 19:42:01 +0000 User-Agent: KMail/1.9.5 References: <45A87011.8080203@gmail.com> <20070116150027.GA17519@snarc.org> <1168969667.5178.18.camel@rosella.wigram> In-Reply-To: <1168969667.5178.18.camel@rosella.wigram> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200701161942.01541.jon@ffconsultancy.com> X-Miltered: at discorde with ID 45AD2AED.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 compiler:01 ocaml:01 threads:01 variants:01 unboxing:01 mult:01 mult:01 higher-order:01 endure:98 frog:98 wrote:01 caml-list:01 functions:01 functions:01 On Tuesday 16 January 2007 17:47, skaller wrote: > In fact I have used Ocaml in a telco environment .. using > the nice Event module, with many threads, services, > and clients interacting in (soft) real time. That was some > time ago so I can't say if I would have used 'finally' > in that context or not. But typically I do that kind of > thing the C way, which is generally the Ocaml way too: > you propagate return codes from functions using variants > up call chains. Choosing boxing and unboxing over exceptions is fine if you have that choice and are willing to endure the performance degredation and added verbosity. However, you only have that choice if your code is self-contained. If you're writing a library where users can raise exceptions, you must be careful to undo state changes. In OpenGL, for example: let transform m k x = GlMat.push(); GlMat.mult m; try k x; GlMat.pop() with e -> GlMat.pop(); raise e could be rewritten: let transform m k x = GlMat.push(); GlMat.mult m; try k x finally GlMat.pop() Handling user-raised exceptions in this way is likely if you're using higher-order functions. -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. Objective CAML for Scientists http://www.ffconsultancy.com/products/ocaml_for_scientists