Syntax...

Paul Benedict pbenedict at apache.org
Sat Nov 21 18:34:31 PST 2009


Neal et. al.,

> I would probably want to use something like 'fun' in place of '#' for
> function types, and 'lambda' or 'fun' in place of '#' for lambda
> expressions.
>
> fun int(int) plus1 = lambda (int x) x+1;
>
> I also prefer the result type on the right-hand-side of a function types,
> but some people seem to have trouble with that:
>
> fun (int)->int plus1 = lambda (int x) x+1;

I think the idea of context-sensitive keywords is very astute. It
would certainly be very readable as it indicates a "closure type"
quite easily.

As for "fun", it does seem .. well, kind of funny. I hope another
context-sensitive keyword can be found. Otherwise, I still think this
is clearly readable though:
int(int) plus1 = lambda (int x) x+1;

Some already said "lambda" or "fun" might not be 100% backwards
compatible. I know that's a lofty goal, but is it absolutely
necessary? I imagine people who write "lambda" in their source are
doing esoteric things like writing math libraries. Otherwise, I can't
froresee a great impact to the developer population.

Paul


More information about the closures-dev mailing list