function types syntax

Rémi Forax forax at univ-mlv.fr
Tue Jan 5 16:50:31 PST 2010


Le 06/01/2010 00:59, Neal Gafter a écrit :
> On Tue, Jan 5, 2010 at 3:53 PM, Rémi Forax<forax at univ-mlv.fr>  wrote:
>    
>> In this case, the only problematic point is that this syntax requires
>> changes to the grammar that will be hard to implement.
>>      
> I'm not sure whether or not that's true, but in any case it isn't
> really an argument against the syntax.  The compiler only has to be
> implemented once, while the benefits of an improved syntax (generally
> speaking, presuming the syntax is better) accrue to all users of the
> language.
>    

Just remember that Java is a spec, and a spec is usually
not implemented once.
Javac will have to implement it, ecj too. All dialects of
Java like by example Groovy, beanshell will have to implement it too.
ANTLR will provide a grammar, SableCC also, etc.

> Having said that, I believe a function type syntax using only parens
> is hard to read, especially when combined with the shorthand
> invocation syntax.  What does this mean:
>
> (x(y))(z)
>
> Perhaps it is casting the value of z to the function type x(y), or
> perhaps it is invoking the method x on the argument y resulting in a
> value of function type to be applied to the argument z.  We could come
> up with rules to disambiguate them, but programmers will still get
> confused.  That's why we abandoned the syntax after BGGA version 0.1
> http://www.javac.info/closures-v01.html .
>    

It can also conflict with () if parenthesis are used to invoke a lambda.

> Cheers,
> Neal
>    

cheers,
Rémi


More information about the lambda-dev mailing list