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=1.2 required=5.0 tests=AWL,MAILTO_TO_SPAM_ADDR, SPF_NEUTRAL 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 A6190BC0A for ; Sat, 13 Jan 2007 08:41:37 +0100 (CET) Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.187]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l0D7fbGb010596 for ; Sat, 13 Jan 2007 08:41:37 +0100 Received: by nf-out-0910.google.com with SMTP id q29so1506428nfc for ; Fri, 12 Jan 2007 23:41:24 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=rqHvhfPMH8cctnKJCQB/SF0J+6dwFTudr/03kdjObDnK+j1uompdx6KJ29lOPj6wgIdCk9ibr0AZLBaM5rNA5h34MPsvvYz6qHAZcl43L2GaRYCRITIl1jCRn1hHg18xQ3NJuP4Oe2REjcrRpSvk1weT6Pd0vBTNVAQZUGvZM44= Received: by 10.82.152.16 with SMTP id z16mr277692bud.1168674083872; Fri, 12 Jan 2007 23:41:23 -0800 (PST) Received: by 10.82.140.13 with HTTP; Fri, 12 Jan 2007 23:41:23 -0800 (PST) Message-ID: <53c655920701122341l3b95328clf4e9ee40d5656dde@mail.gmail.com> Date: Sat, 13 Jan 2007 08:41:23 +0100 From: "David Baelde" Reply-To: david.baelde@ens-lyon.org To: "Edgar Friendly" Subject: Re: [Caml-list] Ocaml compiler features Cc: caml-list@yquem.inria.fr In-Reply-To: <45A87011.8080203@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <45A87011.8080203@gmail.com> X-j-chkmail-Score: MSGID : 45A88D31.001 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 45A88D31.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 compiler:01 foo:01 ocaml:01 camlp:01 compiler:01 syntax:01 foo:01 edgar:98 wrote:01 precedence:01 precedence:01 clearer:01 caml-list:01 define:01 On 1/13/07, Edgar Friendly wrote: > I understand that the let statement groups the following compound > expression into one statement for the then-clause, so it's a precedence > problem. Would it really be enough to raise the precedence of ; higher > than that of if/then? Is there any reason this hasn't been done already? It may be useful to note that some people might want to write code like: foo ; x <- if y then a else b ; bar ; In that example bar is really meant to be outside the if-then-else. OCaml has no such thing as statements, but only expressions. But let me use these words: you want a statement-level if-then-else with lower precedence than ";", it cannot be the same as this expression-level if-then-else with higher precedence than ";". If you're bored with begin/end a good solution might be to define a new construct using camlp4 instead of hacking the compiler. It's the good advice in general for syntax problems. my_if condition my_then foo ; x <- if y then a else b ; bar ; my_else etc Of course one wants better keywords than this. Finally, I'd made the closing of that new if mandatory, it seems clearer. Hope that helps. -- David