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=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 7549ABC0B for ; Wed, 17 Jan 2007 12:50:52 +0100 (CET) Received: from hades.snarc.org (hades.snarc.org [212.85.152.11]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l0HBoqaY005123 for ; Wed, 17 Jan 2007 12:50:52 +0100 Received: by hades.snarc.org (Postfix, from userid 1000) id 0666B1B481; Wed, 17 Jan 2007 12:50:04 +0100 (CET) Date: Wed, 17 Jan 2007 12:50:04 +0100 To: skaller Cc: Jon Harrop , caml-list@yquem.inria.fr Subject: Re: [Caml-list] Ocaml compiler features Message-ID: <20070117115003.GB28532@snarc.org> References: <45A87011.8080203@gmail.com> <20070116150027.GA17519@snarc.org> <1168969667.5178.18.camel@rosella.wigram> <200701161942.01541.jon@ffconsultancy.com> <1169005573.8941.90.camel@rosella.wigram> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1169005573.8941.90.camel@rosella.wigram> X-Warning: Email may contain unsmilyfied humor and/or satire. User-Agent: Mutt/1.5.13 (2006-08-11) From: tab@snarc.org (Vincent Hanquez) X-Miltered: at concorde with ID 45AE0D9C.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 compiler:01 mult:01 higher-order:01 mult:01 syntax:01 ocaml:01 abstraction:01 cheers:01 wrote:01 wrote:01 idiom:01 exception:01 caml-list:01 functions:01 On Wed, Jan 17, 2007 at 02:46:13PM +1100, skaller wrote: > > 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. > > > Of course any specific example has a work around: > > let finally u f = try u () with e -> f (); raise e in > > let u () = GlMat.push(); GlMat.mult m in > let f () = GlMat.pop() in > finally u f Again, it would more convincing if the code you wrote was correct. Here the f function doesn't get call if u didn't raise an exception. We want the f function to be called in ALL case. > This would, however, be a mess if the push/pop things were > nested (which is likely I guess). Felix provides the syntax This is not about Felix. > which is very convenient for this idiom: > > finally { push GlMat; mult GlMat m; } { pop GlMat; }; And I would wrote it in OCaml with the abstraction function I have: finally (fun () -> push GlMat; mult GlMat m) (fun () -> pop GlMat); See, you can also show what you want to show without talking about language X on language Y's ML, and thus been more on topic. Cheers, -- Vincent Hanquez