The IntelliJ IDEA editor (9+) has a feature called "closure folding" for
Java code that makes:

Runnable r = new Runnable() {
    public void run() {
        System.out.println( "Hello" );
    }
};

display and read like:

Runnable r = Runnable() { System.out.println( "Hello" ); };

With the "Runnable () {" and "}" grayed out to make it even easier to read.
 Here's a link with more information and screenshots:
http://blogs.jetbrains.com/idea/2009/03/closure-folding-in-intellij-idea-9-maia/

Furthermore, with autocomplete, all the user has to type to create this code
block is Runnable r = new <autocomplete>System.out.println("hello");

So we can conclude a few things:
1. JetBrains considers Java to have closures
2. With appropriate tool support, Java closures can be easy to read and
write

Sam

On Tue, Sep 13, 2011 at 5:04 AM, Russel Winder <[email protected]> wrote:

> On Tue, 2011-09-13 at 07:27 +0100, Kevin Wright wrote:
> >
> [ . . . ]
> > This breaking news, just in: C has objects, and Lisp has static types.
> >
> > More details to come as events unfold.
> >
> :-)
>
> Kevin,
>
> In reading the entries for this thread, I was at a loss as to where to
> dive in.  Thanks for providing a cue!
>
>
> C++ prior to C++11 has what is effectively closures in that you can
> create instances of classes with an operator ( ) overload and ensure
> that the constructor requires parameters such that an instance of the
> class has no free variables.  This technique has now been folded into
> the lambda functions introduced in C++11 and given a specialist syntax
> so people don't have to roll their own.
>
> Java not allowing operator overloading makes this just a tiny bit more
> verbose:  you have to call the function call or something.  Nonetheless
> the same programming idiom applies.
>
> The issue here is the difference between "infrastructure that allows"
> and "syntax that represents".  Having "syntax that represents" is a
> raising of the abstraction level that means (generally) that the
> language is easier for programmers to write good programs.  Clearly
> there are counter-examples, but the point remains.
>
> --
> Russel.
>
> =============================================================================
> Dr Russel Winder      t: +44 20 7585 2200   voip:
> sip:[email protected]
> 41 Buckmaster Road    m: +44 7770 465 077   xmpp: [email protected]
> London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
>

-- 
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