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 F147DBC0B for ; Tue, 16 Jan 2007 07:51:52 +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 l0G6pona025807 for ; Tue, 16 Jan 2007 07:51:51 +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:21:49 +1030 X-IronPort-AV: i="4.13,194,1167571800"; d="scan'208"; a="72138943:sNHT21454734" Subject: Re: [Caml-list] Ocaml compiler features From: skaller To: Edgar Friendly Cc: caml-list@yquem.inria.fr In-Reply-To: <45AC60CB.4070408@gmail.com> References: <45A87011.8080203@gmail.com> <20070115103556.GB12311@furbychan.cocan.org> <45AC60CB.4070408@gmail.com> Content-Type: text/plain Date: Tue, 16 Jan 2007 17:51:45 +1100 Message-Id: <1168930305.5513.27.camel@rosella.wigram> Mime-Version: 1.0 X-Mailer: Evolution 2.6.1 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 45AC7606.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 compiler:01 syntax:01 elif:01 unambiguous:01 elif:01 ambiguities:01 endmatch:01 ocaml:01 unambiguous:01 semantics:01 edgar:98 sourceforge:01 wrote:01 wrote:01 On Mon, 2007-01-15 at 23:21 -0600, Edgar Friendly wrote: > Richard Jones wrote: > No, I want to make the following code legal: > > if y = 1 then > print_int y; > print_int z; > else > print_string "not one" > > > It's just an unnecessary stumbling block for programmers coming from > other languages. So is your syntax: if cond1 then e1 elif cond2 then e2 .. else el endif is THE correct, unambiguous, formulation, and what Felix uses . For procedural code: if cond do .. elif .. .. else .. done These forms were decided by Wirth after the Pascal ambiguities, and his next attempt, Modula, uses them. Felix also uses match .. with .. endmatch but strangely has an open let .. in ... whereas Standard ML uses let .. in .. end Ocaml uses a closed form here: for .. do .. done Felix, like C++, also has ; as a statement terminator not a separator. Research was done on this (no I can't cite it). Terminators are known to be better :) Closed forms are precedence free, allow an unambiguous grammar, and support easy cut and paste: all in all, these syntaxen obey an important rule: the substitution principle. However, they lead to excess terminators, and so most languages close some forms and leave others open. IMHO Ocaml leaves too many open, but this is just a minor taste issue: what really interested me is the semantics. BTW: Python solves the excess terminator problem by using indentation, which is generally quite nice, IMHO, though it makes code containing long quoted strings very ugly. -- John Skaller Felix, successor to C++: http://felix.sf.net