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: Edgar Friendly <thelema314@g...>
Subject: Re: [Caml-list] Ocaml compiler features
David Baelde wrote:
> > On 1/13/07, Edgar Friendly <thelema314@gmail.com> 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.
> >

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

> > 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 ";".

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?

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

E.