function types syntax

Peter Levart peter.levart at gmail.com
Wed Jan 6 07:21:14 PST 2010


On Wed, Jan 6, 2010 at 12:59 AM, Neal Gafter <neal at gafter.com> wrote:

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


Programmers following Java naming conventions are usually not confused when
faced with:

String vs. string

Likewise the example above would be either:

(X(Y))(z)

or:

(x(y))(z)

But the example is syntactically ambiguous so that's it. The end of the
story.

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 .
>
>
I think it's far more important to enable short invocation syntax for
functions than dropping one character from function types syntax.

Speaking of short invocation syntax. Not only is it ambiguous when faced
with variable name of function type vs. method name, but also this:

(a)(b)

can be interpreted either as casting value of b to type a, or invoking
function a with argument b.

Cheers,
> Neal
>
>
Regards, Peter


More information about the lambda-dev mailing list