|Pathologically Eclectic Rubbish Lister|
Re^4: Closure on Closures (beta)by adrianh (Chancellor)
|on Jul 08, 2003 at 00:13 UTC||Need Help??|
I think the "normal CS definition of a closure" is a pretty elusive beast; mythical, maybe.
The The Free On-line Dictionary of Computing's
a closure is a data structure that holds an expression and an environment of variable bindings in which that expression is to be evaluated.
works for me.
A closure is code that retains a binding to a free variable even after the variable has gone out of scope.
Close enough :-)
I suggested that the closure is actually created when the sub is first entered via the goto.
So is this a closure?:
I don't think the above, or your original example, meet your or my definitions of a closure.
The variable bindings are not retained - because we don't get 100, 101, etc. That binding is an essential part of what a closure is all about.
Really, it's very similar to broquaint 's "named closure" example; only, the inner block is not a subroutine
I don't think it is because "named" closures retain the variable bindings of their scope they were declared in.
I do agree with you and broquaint that the Camel's definition is off. Closures and naming are separate concepts. It seems to be one of those things that Perl defines differently from the rest of the world :-) Why should a closure suddenly become something else if its assigned to a symbol table entry.