in reply to •Re: Re: Toggling between two values
in thread Toggling between two values
"closure" and "named" are orthogonal properties
I'm afraid that's not quite true, at least in Perl. Perl subs that are named are not closures, by fiat. This choice was made to prevent imposing closure overhead on subroutines that don't need closure behavior (i.e. the capturing of values at time of sub reference).
The rule, as best I recall, is: In Perl, a closure is an anonymous subroutine that accesses at least one lexical variable not declared at global scope. BTW, IIRC, BEGIN blocks are deemed to be global scope for the purpose of deciding whether a sub is a closure.
I do feel a bit weird correcting chip on this point.
Well, you should, since you're wrong. {grin}
-- Chip Salzenberg, Free-Floating Agent of Chaos
|
---|
Replies are listed 'Best First'. | |
---|---|
•Re: Re: •Re: Re: Toggling between two values
by merlyn (Sage) on May 05, 2003 at 17:46 UTC | |
by chip (Curate) on May 05, 2003 at 18:02 UTC | |
Re: Re: •Re: Re: Toggling between two values
by jdporter (Paladin) on May 05, 2003 at 20:03 UTC | |
by chip (Curate) on May 05, 2003 at 20:21 UTC | |
by jdporter (Paladin) on May 06, 2003 at 12:46 UTC | |
by chip (Curate) on May 07, 2003 at 21:08 UTC |
In Section
Seekers of Perl Wisdom