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 71416BC0B for ; Wed, 17 Jan 2007 15:09:56 +0100 (CET) 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 l0HE9rTi024879 for ; Wed, 17 Jan 2007 15:09:55 +0100 Received: from ppp27-234.lns1.syd6.internode.on.net (HELO rosella) ([59.167.27.234]) by ipmail01.adl2.internode.on.net with ESMTP; 18 Jan 2007 00:39:51 +1030 X-IronPort-AV: i="4.13,199,1167571800"; d="scan'208"; a="75132385:sNHT22542639" Subject: Re: [Caml-list] Ocaml compiler features From: skaller To: Vincent Hanquez Cc: caml-list@yquem.inria.fr In-Reply-To: <20070117114104.GA28532@snarc.org> References: <20070115000544.GA28731@snarc.org> <20070115221717.GA9982@snarc.org> <1168910291.9207.62.camel@rosella.wigram> <20070116090002.GA14494@snarc.org> <1168956872.5332.28.camel@rosella.wigram> <20070116150027.GA17519@snarc.org> <1168969667.5178.18.camel@rosella.wigram> <45AD2672.2090206@gmail.com> <1169004527.8941.77.camel@rosella.wigram> <20070117114104.GA28532@snarc.org> Content-Type: text/plain Date: Thu, 18 Jan 2007 01:09:46 +1100 Message-Id: <1169042986.5343.14.camel@rosella.wigram> Mime-Version: 1.0 X-Mailer: Evolution 2.6.1 Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 45AE2E32.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 compiler:01 0100,:01 ocaml:01 trivial:01 exn:01 exn:01 lacks:01 generality:01 sourceforge:01 wrote:01 wrote:01 exception:01 exception:01 caml-list:01 On Wed, 2007-01-17 at 12:41 +0100, Vincent Hanquez wrote: > On Wed, Jan 17, 2007 at 02:28:47PM +1100, skaller wrote: > > That is a reasonable argument to examine: but I'm not sure > > finally is actually all that useful. If you're thinking of: > > > > try maybe_throw X; do something > > finally -> cleanup done > > > > then it can be coded in Ocaml like: > > > > begin try maybe_throw X; do something; cleanup > > with x -> cleanup; throw x end > > It would be more convincing if you hadn't made the trivial mistake to > put the first cleanup function in the try. > if for a really weird reason cleanup raises an exception, cleanup is done twice. > > the correct OCaml code is: > > let r = try maybe_throw X; do something; with exn -> cleanup; raise exn in > cleanup; > r My code lacks generality, in that it assumed the expression returned the unit. I see no difference whether the cleanup is in the try or not: did I miss something? [Well yes .. if the cleanup can raise an exception .. :] > the point is not it's hard to do, it's annoything to duplicate here and > there, and doing the inline code lose the higher level view we can have > with a syntaxic sugar like try-finally. I don't dispute these claims. However the same is true for many features. We don't want to implement them all, so how do we choose? The C++ committee basically chose features which either: (a) were extremely common (b) were so complex many people would get it wrong (c) couldn't be done any other way In addition, the C++ committee had limited time and couldn't do everything. So a choice of a few features had to be made. Some were accepted simply because they met the criteria and were easy to implement, and others, although harder, provided great benefit. Given all these factors .. would you REALLY chose 'finally' as a feature? If I gave you just three features you could add .. would you REALLY waste one of your wishes on 'finally'? > seems that you *finally* understand it ;) Lol! I have no trouble understanding it. See above. My issue is with whether it is really that useful and common it really should be part of an already over rich language. -- John Skaller Felix, successor to C++: http://felix.sf.net