
State of the (Java) Lambda - gthank
http://cr.openjdk.java.net/~briangoetz/lambda/lambda-state-2.html
======
RodgerTheGreat
Well, at the very least the new syntax is a tremendous improvement upon the
previous proposals. (<http://cr.openjdk.java.net/~mr/lambda/straw-man/>)

Compare the old

    
    
      #(int x)(x + x)
    

To the new

    
    
      {x -> x + x}
    

Much more consistent with the syntax of normal Java. Seems to be borrowing
from C#.

~~~
evilduck
I hadn't followed up on it since the previous proposal but....thank goodness.

The pound-sign lambda annoyed me since other lambda capable languages use it
to denote comments. It wasn't a dealbreaker, but it certainly was less than
preferred.

~~~
cabalamat
I agree. I know of no other language where a # is used to denote lambdas. I
would prefer one of:

1\. a keyword such as fn, fun, function, lambda. (Incidently, my language uses
fn)

2\. {...} are used to denote code blocks in many languages, including Java

3\. -> or => are also used for functions in several languages (IIRC C# uses
=>)

~~~
Zak
# is used for lambda shorthand in Clojure. #(+ % %2) is shorthand for (fn [x
y] (+ x y)).

~~~
cabalamat
That's a nice shorthand. AIUI, Arc uses [... _ ....] as a terse shorthand for
closures, but can only deal with functions that take one argument that way --
though it would be simple to expand Arc so it could say [+ _ _2].

Now I've thought about it, I may add something similar as syntax in Unify: (tn
+ _ _2) (where tn stands for "terse function")

------
shadowfox
Is it still part of Java 7 release?

------
jcdreads
Instead of {x -> x + 1} you could always run clojure on your existing
production JVM and write #(+ % 1) to get the same effect.

------
navteniev
I find the use of "yield" a little strange. In Ruby yield, yields the
execution to the block that was passed in as an argument to the method being
invoked. In this proposal it would replace the "return" statement inside a
lambda.

~~~
warmfuzzykitten
In other languages, yield is used for coroutine (continuation) return. Bad
choice. There is actually no reason not to use return, or to disallow break
and continue. These could all have the same meaning as they do in a SAM
implemented with an inner class.

