When the foreach syntax (for(:)) has been
introduced in 1.5, a recurring question was
why foreach is not able to
iterate using an iterator.
I think i have a trick to do that using the
syntax of the closure :
Iterator<String> scanner=new Scanner(System.in);
for(String word:() { scanner })
System.out.println(word);
Why this code works. The foreach statement needs
an array...
As seen in Neil Gafter's blogs, there are two rival proposals
about adding closure to Java language.
The first one, named v0.1, introduces a new kind of
type, function type in order to express the type of a closure.
The second one, named v0.2, enables to use
interface as type of closure.
The goal of this entry is to show the pro and cons of the
two proposals.
Let me take an example...
A new version of the closure proposal
has been post at the end of this week by Neal Gafter
and proposes in section 3 to tag parameter
with a special keyword to differenciate between
synchonous and asychronous closure.
For me this section contains two flaws, the first one is that
the keyword used is synchronized, the second one
is to not recognize that such feature can be usefull in...
In my last post, i've described how to use jrunscript to
create a build script.
As olivier wrote in the comments, the build process is usually
a dependency graph and jrunscript doesn't do that by default.
But javascript is far more powerful than XML
thus it's easy to create commands that enable to declare
dependencies betweeen functions as Ant or make does.
I propose the following...
The JDK6 provides a new command jrunscript
that enables to execute script shell in Java environment.
By default, jrunscript uses javascript as scripting language
and provides some useful default functions like cp, cd, cat, etc.
These global functions seem designed to ease the creation of
build scripts, so i propose to show the basics of how
to write such scripts.
First, the script...
In a previous entry, i've written about declaring a method
that doesn't return normally using null,
the type of null, as return type.
A comment from Neal Gafter make me realize that i was wrong
but i now think the closure spec is wrong too.
What the closure proposal says is that a function that doesn't
return normally should use null.
Not the converse, so i agree with neal that a...
The closure proposal doesn't define how closure and
collections will work together.
It's reasonable to say that this API will exist
because closure in order to be accepted
by the community must be well integrated with collections.
After all, java.util is the second more used package after
java.lang.
But that is not so easy.
In a dream world, collection should have method like...
Wow, we begin to have a good view
of the language enhancements planed for Dolphin JDK7.
XML Syntax : blog entry
by Mark Reinhold
Super-packages : blog entry
by Gilad Bracha
Closure : a blog entry
by Peter Ahé
Annotations to detect software failure : JSR 305
submitted by Bill Pugh.
Like any geek, i'm not sure to be able to wait 2 more years
before...
I'm seating in my garden, my laptop on my knees.
i'm hearing the noise of some mowers in the background,
my kid is sleeping,
my wife is trying to resolve a sudoku,
and i'm thinking about closure, again !
Why doesn't enable to define a closure using a reference
to a method ?
public class HelloClosure {
public void sayHello(String name) {
System.out.println("hello "+name...