in reply to Re^2: nested routines, anonymous routines and location dependency
in thread nested routines, anonymous routines and location dependency
IOW direct named subroutine declarations can only bind to a static lexical environment, but anonymous subs can close over any lexical environment in play at the moment of instantiation. You can even create multiple instances of the "same" anonymous sub.
IIRC one of the reasons for this distinction is that you can take references to named subroutines that haven't been evaluated yet. This is useful, but it comes with certain disadvantages.
In any case, I can't think of any example where you can't move the anonymous subs to some other location to solve the problem in your original post. In general, moving the subs makes everything clearer too.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: nested routines, anonymous routines and location dependency
by Anonymous Monk on Mar 04, 2008 at 23:25 UTC | |
by chromatic (Archbishop) on Mar 04, 2008 at 23:40 UTC | |
by QM (Parson) on Mar 06, 2008 at 14:17 UTC | |
by ikegami (Patriarch) on Mar 04, 2008 at 23:42 UTC | |
by ysth (Canon) on Mar 05, 2008 at 02:32 UTC |