Java Closures Tutorial
JSR Proposal: Closures for Java, section 2:
'This JSR provides support for operating on an arbitrary "block of Java code", or body, which is either a statement list, an expression, or a combination of both. We call the mechanism a closure expression. Wrapping statements or an expression in a closure expression does not change their meaning, but merely defers their execution. Evaluating a closure expression produces a closure object. The closure object can later be invoked, which results in execution of the body, yielding the value of the expression (if one was present) to the invoker. A closure expression can have parameters, which act as variables whose scope is the body. In this case the invoker of the closure object must provide compatible arguments, which become the values for the parameters.'
This tutorial does not describe the whole proposal but only the features implemented in the prototype compiler. All examples in this tutorial were tested against the early prototype available at http://www.javac.info. Current version: closures.tar.gz