I’m a bit confused as to the term “closure” used within the Groovy documentation. According to the documentation, their definition of a closure seems more like an anonymous function or lambda.
I understand that languages that support first class functions, typically allow closures to be formed. However, there is a distinction between the two concepts.
For example, according to the Groovy docs:
A closure in Groovy is an anonymous
chunk of code that may take arguments,
return a value, and reference and use
variables declared in its surrounding
scope.In functional language parlance, such an anonymous code block might be referred to as an anonymous lambda expression in general or lambda expression with unbound variables or a closed lambda expression if it didn’t contain references to unbound variables (like threshold in the earlier example). Groovy makes no such distinction.
Then according to the Wikipedia page on Closures:
The term closure is often mistakenly used to mean anonymous function.
What am I missing?
As it says in the next paragraph of the same page you linked to in the groovy docs: