Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: DESTROY and AUTOLOAD in 5.20.1by Anonymous Monk |
on Apr 24, 2015 at 18:05 UTC ( [id://1124591]=note: print w/replies, xml ) | Need Help?? |
"Fascinating," as Mr. Spock would say. I do not understand it either, but I can say from experimentation that DESTROY() stopped getting dispatched through AUTOLOAD() starting with Perl 5.18.0. Perl 5.16.3 shows the behavior we both expect. I no longer have 5.17.* available for testing. Now, perl5180delta does not contain the word "DESTROY". But perl5200delta notes a bug fix to a change in DESTROY() dispatching that was introduced in 5.18. I wonder if this behavior was introduced at the same time. I also wonder whether this is a bug or a feature. My vote is for the former, based on the principal of least surprise. A separate surprising thing (at least to me) is that your code declares DESTROY as though it were a scheduled block, not a subroutine. Well, that in itself does not surprise me, the surprising thing to me is that it works when declared this way. The perlsub documentation refers me to perloo for DESTROY(), and perloo declares it as a subroutine. But the "scheduled block" syntax (i.e. no "sub" keyword) works for every Perl I tried, all the way back to 5.6.2. -- Tom Wyant
In Section
Seekers of Perl Wisdom
|
|