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 6181DBC0B for ; Tue, 16 Jan 2007 07:33:34 +0100 (CET) Received: from ipmail02.adl2.internode.on.net (ipmail02.adl2.internode.on.net [203.16.214.141]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l0G6XVmN021390 for ; Tue, 16 Jan 2007 07:33:33 +0100 Received: from ppp14-213.lns2.syd7.internode.on.net (HELO rosella) ([59.167.14.213]) by ipmail02.adl2.internode.on.net with ESMTP; 16 Jan 2007 17:03:29 +1030 X-IronPort-AV: i="4.13,193,1167571800"; d="scan'208"; a="72131726:sNHT215432182" Subject: Re: [Caml-list] Ocaml compiler features From: skaller To: Jon Harrop Cc: caml-list@yquem.inria.fr In-Reply-To: <200701160211.02613.jon@ffconsultancy.com> References: <45A87011.8080203@gmail.com> <20070115221717.GA9982@snarc.org> <1168910291.9207.62.camel@rosella.wigram> <200701160211.02613.jon@ffconsultancy.com> Content-Type: text/plain Date: Tue, 16 Jan 2007 17:33:24 +1100 Message-Id: <1168929204.5513.9.camel@rosella.wigram> Mime-Version: 1.0 X-Mailer: Evolution 2.6.1 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 45AC71BB.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 compiler:01 recursion:01 syntax:01 syntax:01 idioms:01 ocaml:01 sourceforge:01 wrote:01 imho:01 rec:01 caml-list:01 exceptions:01 define:01 primitives:01 On Tue, 2007-01-16 at 02:11 +0000, Jon Harrop wrote: > try ... finally is useful when closing file handles. [] > Solution is to box and unbox, moving the tail-recursive call outside the try > block: > > let rec read ?(t=[]) ch = > match try Some(input_line ch) with End_of_file -> None with > | Some h -> read ~t:(h::t) > | None -> t > > Inelegant. But what I do all the time to eliminate exceptions, which in general I dislike. In my context let entry = try Some (Hasthtbl.find tbl key) with Not_found -> None in match entry with | Some v -> | None -> No issue of recursion here. Of course, it is easy to just define the first line as a function, encapsulating the inelegance at the expense of readers needing to know what an undocumented function does. But is it the job of a language to provide syntax for everything? Usually languages provide syntax which spans the primitives and a bit more covering really common idioms .. and leaves the rest to the library. A too rich syntax is harder to learn IMHO, for example Ocaml classes are hard to learn. I've been writing Ocaml for a while and still have no idea what the difference between a method interface in a class type and a virtual method is. -- John Skaller Felix, successor to C++: http://felix.sf.net