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 discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 1FFCEBC69 for ; Mon, 20 Aug 2007 07:23:30 +0200 (CEST) Received: from ptb-relay02.plus.net (ptb-relay02.plus.net [212.159.14.213]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l7K5NTad021096 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Mon, 20 Aug 2007 07:23:29 +0200 Received: from [80.229.56.224] (helo=beast.local) by ptb-relay02.plus.net with esmtp (Exim) id 1IMzjT-0002lH-42 for caml-list@yquem.inria.fr; Mon, 20 Aug 2007 06:23:28 +0100 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] If OCaml were a car Date: Mon, 20 Aug 2007 04:37:59 +0100 User-Agent: KMail/1.9.7 References: <56864F61-40F3-4F03-9823-6D510AD5320B@epfl.ch> <1187559941.6987.40.camel@rosella.wigram> In-Reply-To: <1187559941.6987.40.camel@rosella.wigram> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200708200437.59877.jon@ffconsultancy.com> X-Miltered: at discorde with ID 46C92551.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 ocaml:01 expr:01 expr:01 bool:01 syntax:01 camlp:01 language's:01 syntax:01 haskell:01 a-b:01 tweaking:01 frog:98 parsed:01 wrote:01 I'm quite surprised to hear so many non-specific complaints. There are, as always, some tweaks I'd like to make... On Sunday 19 August 2007 22:45:41 skaller wrote: > Ocaml has lots of syntactic issues. It has too many operators, > so that it is hard to remember their 'precedence'. Some are > very un-natural, for example: > > if e then e1 else e2 > > 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. > Furthermore, because of the decision that procedures > return unit, you can write: > > if e then p; > > without the else, but only if p has type unit: the syntax is so > confused it doesn't know if it is functional/expression based > (in which case the else expression should be mandatory) > or procedural (in which case procedure calls should return void > to prevent the call being used as an argument to an application). Why should the return value (of unit) not be used as the argument to an application? > Well it is NOT clear that all these alternatives are actually > a good idea, just as it is NOT clear that excess use of camlp4 is > a good idea. In my experience, using the language's raw syntax, > even if it has warts, is more or less mandatory if you want > other people to be able to read your code. Yes. > Can Ocaml syntax be improved? Yes, but not much. Felix has: > > print$ "Hello" + " World"; > > which is stolen from Haskell and gets used a lot. Even if I can > implement that with camplp4 I wouldn't. I'd like to see $ in > the standard language: then I'd use it. You might prefer the F# operators |>, << and >>. For syntactic changes, my personal vote goes to some very useful syntactic extensions rather than any replacements, and ones that don't (in practice) break backward compatibility. Boolean expressions could permit: a < b <= c Asymmetric whitespace allows a new unary minus operator with higher precedence: a - b -> Sub(a, b) a -b -> Apply(a, -b) a-b -> Sub(a, b) That's pretty much all I can think of. The rest is fine by me. I'd much rather see effort go into an IDE rather than tweaking the syntax and breaking backward compatibility. -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. OCaml for Scientists http://www.ffconsultancy.com/products/ocaml_for_scientists/?e