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 CAFADBC6B for ; Mon, 20 Aug 2007 12:00:47 +0200 (CEST) Received: from ix2.fz-rossendorf.de (ix2.fz-rossendorf.de [149.220.4.86]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l7KA0luT003206 for ; Mon, 20 Aug 2007 12:00:47 +0200 Received: from localhost (localhost [127.0.0.1]) by ix2.fz-rossendorf.de (Postfix) with ESMTP id DAD5CBC6E; Mon, 20 Aug 2007 12:00:44 +0200 (CEST) Received: from ix2.fz-rossendorf.de ([127.0.0.1]) by localhost (ix2 [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 15873-02-5; Mon, 20 Aug 2007 12:00:44 +0200 (CEST) Received: from fz-rossendorf.de (cg.fzd.de [149.220.4.64]) by ix2.fz-rossendorf.de (Postfix) with ESMTP id 648E9BC56; Mon, 20 Aug 2007 12:00:44 +0200 (CEST) Received: from [149.220.10.42] (HELO localhost) by cg1.fz-rossendorf.de (CommuniGate Pro SMTP 5.1.11) with ESMTP id 501114; Mon, 20 Aug 2007 12:00:44 +0200 Date: Mon, 20 Aug 2007 12:00:40 +0200 From: Joerg van den Hoff To: skaller Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] If OCaml were a car Message-ID: <20070820100040.GB11053@marco.fz-rossendorf.de> References: <56864F61-40F3-4F03-9823-6D510AD5320B@epfl.ch> <1187559941.6987.40.camel@rosella.wigram> <200708200437.59877.jon@ffconsultancy.com> <1187591184.6295.36.camel@rosella.wigram> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1187591184.6295.36.camel@rosella.wigram> User-Agent: Mutt/1.5.13 (2006-08-11) X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at fz-rossendorf.de X-Miltered: at concorde with ID 46C9664F.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; joerg:01 ocaml:01 0100,:01 expr:01 expr:01 bool:01 ocaml:01 btyp:01 elided:01 dfns:01 btyp:01 non-terminal:01 syntax:01 'let:01 semantics:01 On Mon, Aug 20, 2007 at 04:26:24PM +1000, skaller wrote: > On Mon, 2007-08-20 at 04:37 +0100, Jon Harrop wrote: > > > > > > > The thing is that 'else' has a different 'precedence' than 'then'. > > > So you can write: > > > > > > if e then e1 else a; b; c > > > > > > and a,b,c are all executed if the condition is false, > > > > I do not believe this is true. The "b" and "c" are executed in both cases > > because the above is parsed as: > > > > (if e then e1 else a); b; c > > > > which is syntactically uniform: > > > > # (<:expr< (if true then a else a);b;c >>) = > > (<:expr< if true then a else a;b;c >>);; > > - : bool = true > > > > Perhaps you were thinking of this: > > > > if p then t else > > let () = () in > > f1; > > f2; > > f3 > > > > because "let" binds more tightly. > > Well there you go! I've been writing Ocaml almost 10 years and > didn't know that. Here's my real code: > > if ret = `BTYP_tuple [] then "// elided (returns unit)\n","" else > let funtype = fold syms.dfns (`BTYP_function (argtype, ret)) in > > I guess I'm just lucky. From what you say, the grammar is exceptionally > bad: the scope of the 'else' is *extended* by the let/in non-terminal > so it goes past ';' -- that should be a syntax error. > > Roughly a 'loosely' binding operator is extending the scope > of a 'tightly' binding operator: doing that is fragile. For example > if I drop the 'let .. in' part the semantics may** change silently. > > The 'right' way to extend a scope is to use an scope extension > operator with no semantics, such as ( .. ) or begin .. end, > or $ in Felix in Haskell. > > But please note: just because I present this analysis doesn't mean > I believe it 100%. Contrarily .. it is just a data point. It has > to be weighted against other factors: every syntactic form has > both advantages and disadvantages, and it is very dependent > on the client's prior experience. *** > > German, for example, has the ridiculously clumsy grammar of > putting the verb at the end and concatenating adjectives onto > nouns: "Ein Schwartz-Wald-Spatzieren-Gehen" = "A Walk in > the Black Forest" .. literally "A Black Forest Walk Going" > (FYI: a famous jazz number from the '60s). as a ocaml novice I probably would'nt have mailed to this list any time soon and I'm afraid this goes off at a tangent, but anyway: I won't argue against your (probably not so well founded?) assessment of a 'ridiculously clumsy grammar', still what you wrote down as being a german sentence is not even the equivalent to pidgin english. "a walk in the black forest" would simply be "ein Spaziergang im Schwarzwald" with a nearly one-to-one correspondence of the words. "Walking in the black forest" would be "im Schwarzwald spazieren gehen", possible tranlation: "taking a walk in the black forest". to be sure, there _are_ some grammatical idiosyncrasies (cf. e.g. a rather funny small polemic written by mark twain, I believe) -- or so it must seem to non-native speakers. so much in defense of my native language :-). apologies for this intrusion... > > I'd probably fall over laughing at how stupid French is :) > > Except .. I happen to know English is the most absurd language > around. It just happens to be my native language so I'm used > to it. > > ** it's likely I'll get a type error and become very confused, > but that is much better than not getting a type error, which is > quite possible if everything is returning unit. > > *** when I designed Felix I made a decision that the grammar > had to be LALR1 and entirely unambiguous, a choice easily > enforced by using Ocamlyacc (without any %prec rubbish, > and by grepping the .output to make sure there were > no shift/reduce conflicts). > > -- > John Skaller > Felix, successor to C++: http://felix.sf.net > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs