[nem-en] Parentheses
Maurizio Colucci
seguso.forever at tin.it
Fri Sep 10 14:09:44 CEST 2004
On Friday 10 September 2004 13:42, Michal Moskal wrote:
> On Fri, Sep 10, 2004 at 01:17:38PM +0200, Maurizio Colucci wrote:
> > Ah, now I see what you mean. But that is not necessary: that is just the
> > way haskell/ocaml happen to treat that syntax. Nemerle doesn't need to do
> > that. I mean, you don't need to support the concept of partial
> > application to allow that syntax. You could even put a preprocessing step
> > that translates
> >
> > f g (h x);
> >
> > into
> >
> > f(g, h(x));
> >
> > , that is, completely mechanically. That's why I don't understand why
> > Michal says the ocaml syntax is more ambiguous. To me, there seems to be
> > one-to-one correspondence.
>
> f x + 1. It's far from obvious what's going on here. Of course there is
> a rule, it's (f x) + 1, but this is not obvious.
(see below)
> > I agree that is SLIGHTLY more difficult to understand which is the
> > functor and which is the argument, but you quickly learn, and the ocaml
> > idiom always has one parenthesis less.
>
> Nope:
>
> f (x + 1) (x - 1) (v * 12)
>
> vs:
>
> f (x + 1, x - 1, v * 12)
(see below)
> > Which is much desirable, considering that MOST OF THE
> > TIME you write things that needs only one parenthesis:
> >
> > Nemerle:
> >
> > def x = f(y, z);
> >
> > ocaml:
> >
> > let x = f y z;
> >
> > This is a simplification that really makes your life easier, on the long
> > run. Consider it takes two minutes to get used to the ocaml idiom,
> > whereas you have to type parentheses more for the rest of your life. :-)
>
> For me, typing is not the most timeconsuming part of programming.
>
All your insightful remarks make me remember that my original point was not
about the number of parentheses, but about readability. All I wanted to say
is that lambdas in Nemerle have poor readability due to excessive parentheses
(and commas), but I ended up counting the parentheses, which was a silly
thing to do. Sorry for wasting your time. :-)
Let me drop the argument about the number of parentheses and begin again: the
real reason why IMO you should adopt the notation
f x (y+1)
instead of
f (x, y+1)
is NOT to have less parentheses, but to improve the looks of lambdas while
keeping consistency. Because if you change
fun (x, y){x +y}
to
fun x y -> x+y
then to be consistent you have to change everything to this
pseudo-partial-application idiom.
It was just a thought. I understand it might not be worth it :-)
> But again, you will be able to implement this as a macro, when the new
> parser is completed.
Very interesting. Thanks :-)
--
Maurizio Colucci
http://logicaldesktop.sourceforge.net
More information about the devel-en
mailing list