By bloid
via adam-bien.com
Published: Apr 07 2008 / 14:13
The term "closure" is defined as follows:
"In computer science, a closure is a function that is evaluated in an environment containing one or more bound variables. When called, the function can access these variables. The explicit use of closures is associated with functional programming and with languages such as ML and Lisp. Constructs such as objects in other languages can also be modeled with closures"
Comments
Umberto Zappia replied ago:
*A closure is a FUNCTION that refers to free variables in its lexical context.
*A function is a block of code with parameters. It may produce a result value.
*A free variable is an identifier used but not defined by the closure.
I think implementing Closures to the next release of the JDK will bring lots of benefit/flexibility/power, the intend is for Closure to be simple and not to re-consider the whole Java platform (commonly held misconception).
====================================
Main goals for closures are:
*Enable control abstraction APIs
*Concise "function" literals without the problems of anonymous instances
*Interoperate with existing APIs
*Functional and Aggregate Operations
*Simple but powerful
Gregg Bolinger replied ago:
I just wish that Java as a language would stop changing. If Sun/Community wants functional language aspecs then use an existing vm compliant language (groovy, scala, etc) or write a new one. The focus should be on improving the VM. Forget syntax.
sproketboy replied ago:
gdboling is 100% right. Closures and other candy violate the read friendly nature of the Java language. We don't want Java to become a kitchen sink language like C#.
Voters For This Link (11)
Voters Against This Link (2)