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.3 required=5.0 tests=AWL,HTML_MESSAGE,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 D57B7BC0B for ; Sun, 14 Jan 2007 22:47:28 +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 l0ELlS7m006852 for ; Sun, 14 Jan 2007 22:47:28 +0100 Received: by nf-out-0910.google.com with SMTP id q29so1974346nfc for ; Sun, 14 Jan 2007 13:47:28 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=fhsouJs0YbQRIQnv/tL00RAnWcRJaQxMqVwa8KAFx3VaOjHO67eCkiyJl9/s0VrqLBedEfANS6bko3arR8BRUW1UbDf0U6vH7UVdNdMH0vlR6bFZrylkq/iNNAHi59YS+AUy0/1coq2d1QUYt75TqOIyU7kM3rDD1N9NKQdx/0k= Received: by 10.82.105.13 with SMTP id d13mr480096buc.1168811247532; Sun, 14 Jan 2007 13:47:27 -0800 (PST) Received: by 10.82.175.13 with HTTP; Sun, 14 Jan 2007 13:47:27 -0800 (PST) Message-ID: Date: Sun, 14 Jan 2007 22:47:27 +0100 From: Tom To: "Edgar Friendly" Subject: Re: [Caml-list] Ocaml compiler features Cc: caml-list@yquem.inria.fr In-Reply-To: <45AA6966.8010602@gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_105899_22181603.1168811247447" References: <45A87011.8080203@gmail.com> <53c655920701122341l3b95328clf4e9ee40d5656dde@mail.gmail.com> <45AA6966.8010602@gmail.com> X-j-chkmail-Score: MSGID : 45AAA4F0.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 45AAA4F0.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 compiler:01 uncommon:01 uncommon:01 ocaml:01 lowered:98 lowered:98 precedence:01 precedence:01 caml-list:01 parentheses:01 parentheses:01 int:01 int:01 construct:02 X-Attachments: cset="UTF-8" cset="UTF-8" ------=_Part_105899_22181603.1168811247447 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline > > > > I think this is the uncommon case, and deserves the parentheses: > x <- (if y then a else b) ; It's not the uncommon case... It's what's the ?: operator for C++ and Java. I guess it's very common indeed. I think I'm arguing that the precedence of if/then/else is too high, and > maybe should be lowered. Of course this isn't a reasonable thing to > ask, because it'll likely break existing code. Anyone with a way to > have my cake and eat it too? > > Look at nemerle [1], I believe they have the if/then/else construct with the else clause mandatory, and for cases where in OCaml it is ommited, they would use the when keyword. This solves your problem: if y=1 then print_int y; print_int 2; else print_string "not one" is same as if y=1 then ( print_int y; print_int 2; ) else print_string "not one" but when y=1 then print_int y; print_int 2; would be (in OCaml) (if y=1 then print_int y); print_int 2 ------=_Part_105899_22181603.1168811247447 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline


I think this is the uncommon case, and deserves the parentheses:
x <- (if y then a else b) ;

It's not the uncommon case... It's what's the ?: operator for C++ and Java. I guess it's very common indeed.

I think I'm arguing that the precedence of if/then/else is too high, and
maybe should be lowered.  Of course this isn't a reasonable thing to
ask, because it'll likely break existing code.  Anyone with a way to
have my cake and eat it too?


Look at nemerle [1], I believe they have the if/then/else construct with the else clause mandatory, and for cases where in OCaml it is ommited, they would use the when keyword. This solves your problem:

if y=1 then
       print_int y;
       print_int 2;
else
       print_string "not one"

is same as

if y=1 then
       ( print_int y;
       print_int 2; )
else
       print_string "not one"

but

when y=1 then
       print_int y;
       print_int 2;

would be (in OCaml)

(if y=1 then print_int y); print_int 2
------=_Part_105899_22181603.1168811247447--