Global? There ain't any global sir.
Global to all calls to hanoi. External? Non-local? Yet highly coupled.
And _hanoi(@_); would work just as well
That's what I said.
while your tricks with local are unavoidable.
How is localising a var "a trick"? Dealing with package vars is a necessity in Perl, and the first thing you need to know is how to localise them.
It is avoidable, but it's messy and requires a trick to avoid a memory leak.
my $_hanoi; # \ Messy line break $_hanoi = sub { # / ... $_hanoi->(...); # Relatively messy syntax ... }; $_hanoi->(...); undef $_hanoi; # Messy hack to avoid mem leak.
Using local actually cleans up a whole of mess.
Besides the problem is not the local itself, but the typeglob handling.
"The typeglob handling" makes "setting a typeglob" sound falsely ominous. It's a manufactured problem.
What debugging complexities are you speaking of?
The removal of a stack frame creates lying stack traces, not just to users but to debugging tools.
In reply to Re^5: passing subroutine references
by ikegami
in thread passing subroutine references
by joe76
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |