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 concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 237B3BC0B for ; Tue, 16 Jan 2007 15:14:41 +0100 (CET) Received: from ipmail01.adl2.internode.on.net (ipmail01.adl2.internode.on.net [203.16.214.140]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l0GEEcpF022945 for ; Tue, 16 Jan 2007 15:14:40 +0100 Received: from ppp27-234.lns1.syd6.internode.on.net (HELO rosella) ([59.167.27.234]) by ipmail01.adl2.internode.on.net with ESMTP; 17 Jan 2007 00:44:36 +1030 X-IronPort-AV: i="4.13,196,1167571800"; d="scan'208"; a="74654608:sNHT410315591" Subject: Re: [Caml-list] Ocaml compiler features From: skaller To: Vincent Hanquez Cc: Martin Jambon , caml-list@yquem.inria.fr In-Reply-To: <20070116090002.GA14494@snarc.org> References: <45A87011.8080203@gmail.com> <200701141823.32855.jon@ffconsultancy.com> <20070114184148.GA26213@snarc.org> <200701142049.57959.jon@ffconsultancy.com> <20070115000544.GA28731@snarc.org> <20070115221717.GA9982@snarc.org> <1168910291.9207.62.camel@rosella.wigram> <20070116090002.GA14494@snarc.org> Content-Type: text/plain Date: Wed, 17 Jan 2007 01:14:32 +1100 Message-Id: <1168956872.5332.28.camel@rosella.wigram> Mime-Version: 1.0 X-Mailer: Evolution 2.6.1 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 45ACDDCE.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 compiler:01 0100,:01 compiler:01 ocaml:01 recursion:01 kloc:01 syntax:01 sourceforge:01 garbage:01 wrote:01 wrote:01 exception:01 exception:01 caml-list:01 On Tue, 2007-01-16 at 10:00 +0100, Vincent Hanquez wrote: > On Tue, Jan 16, 2007 at 12:18:11PM +1100, skaller wrote: > > I don't miss any of those things .. the point being they're > > not so 'common' as you might think. > > It's totally common to to do some action despite that an exception has > been raised or not to cleanup stuff (like file descriptor is the obvious > example). No it isn't. First, I don't use exceptions like that: I usually wrap them. Second, this technique isn't that useful in a language with garbage collection: this is not C++. A thirdly, in my own language Felix there ARE no exceptions .. so it can hardly be 'common'. The Felix compiler (an Ocaml program) throws exceptions in three circumstances: (a) Errors: no cleanup is required. (b) Library functions: either it is a program error or I map the exception to a variant: no cleanup is required. (c) Exiting a deep recursion: in no case is any cleanup required. So actually in a 60Kloc program, no cleanup is done anywhere for any reason. It just isn't necessary. > > I'm a Python programmer too, and I never use 'finally' .. > > I've never found any use for it. > > You probably don't write/read much python code then. Actually I'm a Python ex-guru, I have two major pieces of software written in it, and I've even *implemented* a Python interpreter .. in Ocaml :) > ( I found 2 use of finally in felix's python code ) Probably written by Erick not me :) > > Felix has return statement .. but then Felix has *statements*: > > executable Ocaml is all expressions, so a return statement would > > seem out of place. > > OCaml is a functional language, however it also contains imperative feature. > > It doesn't seems so inappropriate to have a return statement, as long > it's not abused. If I recall, the revised syntax also has a return statement. I'm simply trying to show that the only way to really substantiate a claim something is common is to do a real survey of code. I have not analysed all the Ocaml code out there but it is my guess most Ocaml programmers would have no real use for a return expression. Many may agree exception handling is not so good, but many would probably favour another proposal for restructuring exceptions, rather than adding a finally clause. I forget the URL of the proposal, which is a kind of let/try construction, perhaps someone can fill that in? -- John Skaller Felix, successor to C++: http://felix.sf.net