[nem-en] Parentheses

nazgul at nemerle.org nazgul at nemerle.org
Wed Sep 8 17:21:47 CEST 2004


On Wed, Sep 08, 2004 at 04:47:29PM +0200, Pawel W. Olszta wrote:
> Hello Maurizio,
> 
> > With the ongoing update to the type inference (I read the Monologue :-)), the
> > only thing that is holding me back from using Nemerle (instead of ocaml) is
> > the heavy notation with too many parentheses, especially for lambdas:
> > 
> > Nemerle:
> > 
> > List.Map ([B()], fun (x) { x.foo });
> > 
> > Ocaml:
> > 
> > List.map [new B]  (fun x -> x#foo)
> 
> I've made a little experiment and you'll probably be able to write:
> 
>     List.Exists ([1, 2, 3, 4, 5], lambda x -> x == 3)

I would rather opt for 
lambda x => x == 3
so we can write also
lambda x : int => x + 3

(of course fun is more desirable ((hmm what a nice sentence ;-) ))
 so we can switch to it after new parser gets implemented)

> 
> The (very simple) `lambda' (as the `fun' keyword is already taken and
> our parser can't differentiate between the two constructions
> automatically yet) macro should make it to tonight's snapshot unless I
> fail to convince Kamil, who's opposing to pollute the language with
> such syntactic sugar.

Yes, I would prefer moving it to Nemerle.Extensions of Nemerle.Lambda
We really shouldn't pollute language with tons of new keywords.
In future we should consider moving it into Core (as syntax addition
to current 'fun').

> 
> > I understand the syntax is meant to be similar to C#, but this should be taken
> > into consideration. Does nobody feel this as a problem?
> 
> Personally, I am a natural born LISP person :)

And I'm natural born LISP killer ;-)

> 
> > PS: Even better would be:
> > 
> > List.Map [B()]  (fun x -> x.foo);
> > 
> > but I understand this would make too much of a change.
> 
> This looks like partial application to me and we're not supporting that.
>

Arguments against are here
http://nemerle.org/rationale.html#call-parens

and it is reasonable to stick with
http://nemerle.org/rationale.html#partial-application

> > PPS: And what about removing () from B()?
> 
> You need the () to differentate the construction of an instance of
> type B from referencing the type B. Moreover the `B ()' notation is
> consistent with the rest of the language.

def f = B;

would currently store reference to constructor, so you can do
def x = f(); // call constructor stored in f as functional value

Now, this is quite consistent:
def g (x) { x + 1 };
def f = g;
List.Map ([1,2], f);
def x = g (4);

The same notation should be used for construction of objects

> 
> And I'd hate to see `()' being replaced by the `new' keyword, it seems
> redundant to me as you have to write the parens anyway if the called
> constructor has any parameters ;]

Get accustomed with all those 'redundant' features, because soon you
will use it more often ;-)  (not in Nemerle of course)

Kamil Skalski





More information about the devel-en mailing list