|
|
| Perl Monk, Perl Meditation | |
| PerlMonks |
Re^3: Why is "any" slow in this case?by ikegami (Patriarch) |
| on Jul 29, 2025 at 11:50 UTC ( [id://11165851]=note: print w/replies, xml ) | Need Help?? |
|
Correct. List::Util::any BLOCK LIST is syntactic sugar for List::Util::any sub BLOCK, LIST because of its prototype.
A sub's access to the variables of the lexical scope in which its defined is called capturing. (A sub that captures is called a closure.) That's not the case for CORE::grep and CORE::any's blocks. Their blocks are no more subroutines than while's.
Note the anoncode (sub { }) in one, and the actual code of the block (match) in the other.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||