Closures
From APIDesign
Closures are classical OOP approach to represent a block of code that can be invoked passing in few parameters. Closures are typical building block of Smalltalk systems. Origin of closures (called lamdas back then) can however be traced many years into the past to λ-calculus (where there is nothing else than invocable blocks of code).
Since their invention closures become almost mandatory syntactic element for any new language. Not having them become a faux pas. As the profound history of programming languages puts it: Java makes them popular by not having them.
Looks like things are about to change. Sun recently announced its will to implement closures for JDK7. To join the overwhelming ecstasy in the Java community I decided to write this page and provide few insights from less conventional angles.
Contents |
The Da Vinci Closures
Everyone who read or saw The Da Vinci Code knows that public statements of those who rule the world need to be taken with a grain of salt. Public speech is there to influence the public behaviour. Not to describe the real estate of things. The real motivations need to remain hiden behind multiple meanings. The goal is to make trustable untrustable and untrustable real. Using irony and self denying references is good. Outsiders who discover part of the truth can never be sure whether it is the grail or just a fake layer around it with completely opposite meaning.
Only paranoid survive. Especially when dealing with Da Vinci and things related to him. One needs to be ready to reveal hidden and surprising meanings. One needs to seek for them.
That is why I was quite surprised that the attempt to extend Java bytecode with invokeDynamic has been named Da Vinci Machine project. What does that mean? Is the proclaimed goal to support multiple languages just a layered public statement and the real goal is somewhere else? What Sun wants public to think? Why?
Now when Sun adopted the idea of closures for JDK7, everything is clear. There was a hidden agenda behind the publicly stated goal.
Method Handle
TBD
Closure as a Handle
TBD