Yea, Java 8 brings nicer syntax for Java's
value-copying-closures-which-are-really-instances-of-anonymous-inner-classes.
Java 8 won't bring any kind of continuation support.

Continuations are a powerful concept. Scheme demonstrates that they
can be powerfully combined with closures. But, it seems to me that
closures and continuations are separable concepts. I don't think
mixing the two concepts helps to clarify things.

That said, the earlier BBGA closure proposal touched on three points:

(1) closures
(2) function types
(3) control abstraction similar to what's shown by the examples in the
linked article (implying a limited kind of continuation support under
the covers.)

What's planned for JDK8 is only #1, where SAM plays the role of #2,
though they say they are leaving the door open for introducing #2 at
some point in the future.

// Ben

On Wed, Sep 14, 2011 at 09:10, Alexey Zinger <[email protected]> wrote:
> Folks, I mentioned this earlier, but no one seemed to pick up on it.  The
> one real difference between closures and constructs like Java's SAM's or
> anonymous functions is how control flow is treated.  Not just in trivial
> cases like branching and looping, but think about continuations, exception
> propagation, etc.  This is where Java comes up short if you wanna do those
> things.  My understanding is that Java 8 syntax doesn't address this, so
> we're still stuck using whatever we had before, but with cleaner, nicer
> presentation (syntax).  Again, not something I consider a deal breaker, but
> an important factor nonetheless.
>
> Alexey
>
>
> ________________________________
> From: clay <[email protected]>
> To: The Java Posse <[email protected]>
> Sent: Tuesday, September 13, 2011 2:15 PM
> Subject: [The Java Posse] Re: Java Has Always Had Closures
>
> Regarding "pass by reference", most people will say Java passes
> objects by reference, when it is more accurate to say that they pass
> object references by value. I don't think there is much confusion or
> debate on that issue.
>
> With Closures, there is a lot of confusion. Java has something
> extremely close to closures, and only a real pedant can debate the
> distinction. I also think when people say that Java lacks closures,
> they are referring to first class functions and concise anonymous
> function syntax instead.
>
> "What you are describing, though, sounds like you really should jump
> ship to one of the alternative languages."
>
> That's actually a different issue: which language is a better fit for
> a project. And I don't disagree, for functional programming support,
> clearly Java is behind the pack. For this thread, I just wanted to
> clarify what a closure is, and what people really mean when they say
> that is missing from Java.
>
> For your loop example, can't you simply do:
>
> for (int x = 0; x < count; x++ ) {
>     final int x2 = x;
>     new Runnable() { public void run() {someFunctionOn(x2);}}.run();
> }
>
> or
>
> for (int x = 0; x < count; x++ ) {
>     someFunctionOn(x);
> }
>
> --
> You received this message because you are subscribed to the Google Groups
> "The Java Posse" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/javaposse?hl=en.
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "The Java Posse" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/javaposse?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to