Don't ask to ask, just ask | |
PerlMonks |
Re^2: Functional Programming & method rewritingby ihb (Deacon) |
on Oct 30, 2004 at 21:21 UTC ( [id://404062]=note: print w/replies, xml ) | Need Help?? |
About closures. I don't generally use the hyper-technical definition that a closure is "anything that closes around a lexical", because that's true of any subroutine that is in a lexical environment. I'm not sure how to interpret you, but it seems we view things differently. Either way a clarification probably would serve well. My definition of a closure in Perl is a subroutine that (deeply) binds a lexical variable. Whether it's called once or twice or a thousand times isn't relevant. It's not about being "hyper-technical", it's about getting at the essence of what a closure is. That the bound variables doesn't go out of scope doesn't make it less of a closure, but its closureness doesn't get used. I understand that this is your point and I can almost sympathize with it, but just almost. It would be very confusing if a subroutine first wasn't a closure, but then became one when it was returned or assigned to variable with a broader scope. Your point is supported by that we don't usually call &foo in a closure. However, it is a closure and it's not wrong calling it one. ihb
See perltoc if you don't know which perldoc to read!
In Section
Meditations
|
|