Syntax...

Paul Benedict pbenedict at apache.org
Sat Nov 21 17:55:06 PST 2009


I would favor -> (dash greater-than) since it does not overload an
existing operator. I suppose that is more readable than # for
closures.

Paul

On Sat, Nov 21, 2009 at 7:30 PM, Mark Mahieu
<mark at twistedbanana.demon.co.uk> wrote:
> It's also worth considering carefully how readable any proposed syntax will
> be when a lambda expression is used as a method argument, or a function type
> used in a method signature.  When I last looked into various options, I
> noted that some forms worked well in the context of a variable declaration
> or assignment, but were rather less easy to parse (for me, not the compiler)
> when they appeared as the type of a method parameter, especially when there
> were two or more parameters.
> On another note, the link to the v0.6a Open Issues page is pointing to v0.5
> at javac.info (although the correct URL isn't hard to guess :-)
> Mark
>
> On 21 Nov 2009, at 20:04, Neal Gafter wrote:
>
> 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
>>
>
>
>


More information about the closures-dev mailing list