LanX has asked for the wisdom of the Perl Monks concerning the following question:
I'm pretty sure the answer is yes, but to be sure:
Are the references to anonymous code blocks in Perl always constant, because they are fixed at compile time?
DB<115> sub tst (&) { print "$_[0]\n" } DB<116> tst {1,2,3,4} for 1..5 CODE(0xa396560) CODE(0xa396560) CODE(0xa396560) CODE(0xa396560) CODE(0xa396560)
Is it reliably so? I took a look at B::Concised opcode output and as far as could see it seemed so...
Please note that it is not the case for anonymous hashes
DB<118> sub tst (%) { print "$_[0]\n" } DB<119> tst {1,2,3,4} for 1..5 HASH(0xa3963f0) HASH(0xa396940) HASH(0xa396720) HASH(0xa3966c0) HASH(0xa3963f0)
Cheers Rolf
( addicted to the Perl Programming Language)
|
|---|