Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: A Real Closureby John M. Dlugosz (Monsignor) |
on Jul 12, 2001 at 18:32 UTC ( [id://96045]=note: print w/replies, xml ) | Need Help?? |
The docs are pretty clear that using sub to create a ref to an anonomous sub will do closures and that a normal named sub will not. So I tried it. It gives me a warning that "$x will not stay shared", but the result seems to work! That is, a created named function seems to reference the same variable as a standard closure created in the same scope, and running the creator again (which makes a different local $x) keeps distinct identities. So what's going on here? Are the docs outdated? Is this working by accident or happenstance? Does the presence of a regular closure somehow make it work? —John
In Section
Seekers of Perl Wisdom
|
|