Closure in java

many known java ppl
“Gilad Bracha, Neal Gafter, James Gosling and Peter von der Ahé”
have posted a proposal for adding closure to java language… this change may be added to JDK 7

http://blogs.sun.com/roller/resources/ahe/closures.pdf or
http://gafter.blogspot.com/2006/08/closures-for-java.html

Gafter: http://gafter.blogspot.com/2006/08/whats-point-of-closures.html
Bracha: http://blogs.sun.com/roller/page/gbracha?entry=achieving_closure
van der Ahé: http://blogs.sun.com/roller/page/ahe?entry=full_disclosure

http://www.javalobby.org/java/forums/t77733.html

(Thank you harald kuhr)

To whom never worked with closure:

http://martinfowler.com/bliki/Closure.html

Example in ruby:

[1,2,4,5].each { |item| puts item }

Example in java (proposed)

Before closure:

void doit(API api) {
api.doRun(new Runnable(){
public void run() {
snippetOfCode();
}
});
}

After closure:

void doit(API api) {
api.doRun(() { snippetOfCode(); });
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

my tweets

August 2006
S S M T W T F
« Jul   Sep »
 1234
567891011
12131415161718
19202122232425
262728293031  

Flickr Photos

RSS my shared links on google reader

  • An error has occurred; the feed is probably down. Try again later.
%d bloggers like this: