I am a little confused about the term "closure" used in the Groovy documentation. According to the documentation, their definition of closure seems more like an anonymous function or lambda.
I understand that languages ββthat support first-class functions usually allow you to create closures. However, there is a difference between the two.
For example, according to Groovy docs:
Closing in Groovy is an anonymous piece of code that can take arguments, return a value, and also specify and use variables declared in the surrounding realm.
In the language of a functional language, such an anonymous block of code can be referred to as an anonymous lambda expression as a whole or a lambda expression with unrelated variables or a closed lambda expression if it does not contain references to unrelated variables (for example, a threshold in an earlier example). Groovy makes no such difference.
Then according to Wikipedia on the Closures page:
The term closure is often mistakenly used to mean an anonymous function.
What am I missing?
closures groovy
Steve
source share