http://qs321.pair.com?node_id=255680


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