Syntax...
Neal Gafter
neal at gafter.com
Sat Nov 21 12:04:36 PST 2009
Vladimir-
We've been carefully avoiding keywords up to now, but I agree using keywords
could result in more natural-reading programs. The problem is the risk of
breaking existing programs. However, that is somewhat less severe now that
there is a syntax for "exotic" identifiers. In JDK7 a keyword can still be
used as an identifier by using the exotic identifier escape syntax. So the
breakage is not as bad as it would have been earlier. It might be possible
to use context-sensitive keywords, too.
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 somepeople seem to have trouble with that:
fun (int)->int plus1 = lambda (int x) x+1;
This latter formulation is neater-looking when there are exceptions in the
function type. For example, this
fun int(int) throws Exception plus1 = lambda (int x) x+1;
reads less well to me than this
fun (int) throws Exception ->int plus1 = lambda (int x) x+1;
Cheers,
Neal
On Sat, Nov 21, 2009 at 11:22 AM, Vladimir Kirichenko <
vladimir.kirichenko at gmail.com> wrote:
> Neal Gafter wrote:
> > Are you proposing "fun" be a new keyword?
>
> Yes. Anyway we need something for disambiguation (in current proposal
> it's # or ^). "fun" looks nice for this. (shorter than function - too
> much letters for limbda construct, and good looking next to class,
> interface and especially enum).
>
> Other languages with pascal-like type manifestation have their let, var,
> val, set.
>
> --
> Best Regards,
> Vladimir Kirichenko
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/closures-dev/attachments/20091121/c9200a13/attachment.html
More information about the closures-dev
mailing list