Version française
Home     About     Download     Resources     Contact us    
Browse thread
Ocaml compiler features
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jon Harrop <jon@f...>
Subject: Re: [Caml-list] Ocaml compiler features
On Sunday 14 January 2007 17:33, Edgar Friendly wrote:
> I think this is the uncommon case, and deserves the parentheses:
> x <- (if y then a else b) ;

Not in a functional language, like OCaml, where you're composing expressions 
into programs. If you want to make a fair comparison you should at least 
start by quantifying how common each is, and whether or not your proposed 
change has knock on effects (e.g. cyclic precedences).

> 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?

Use camlp4 to create some more revised syntaxes.

> > > 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.
>
> Writing things in camlp4 could help me, but won't improve the world of
> ocaml.

It will if you do something more productive with camlp4, like try...finally 
or ...

> I want to compare the situation to TeX / LaTeX -- since you can 
> customize it so much, people fix what they don't like on their local
> copy, but these improvements never make it upstream to improve the
> situation for the world.
>
> I will agree that I am too eager to "fix" the compiler, and appreciate
> the community's help in tempering my inexperience.  But I'd like to help
> ocaml become a better language, and this seems like a reasonable small
> step to start on.

I wouldn't call changing the precedence of "if" a small step...

On a related note, current precedences dictate that this:

  string1^string2 :: list

is parsed as:

  string1^(string2 :: list)

which is useless.

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists