Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re^4: Safely altering the behaviour of heavily used modulesby adamk (Chaplain) |
on Apr 11, 2006 at 04:11 UTC ( [id://542443]=note: print w/replies, xml ) | Need Help?? |
It can't ever work, because of the problem of references. Storable supports circular references correctly, and the implementation of this means that what is in $_[0] may already have 4 or 5 other Perl references pointing to it by the time the hook gets called. So if you were to replace $_[0] with $singleton, you would break all the other references. If Perl references were purely heirachal, this wouldn't be a problem. And that is why we have a seperate method. Because it provides an alternative that certifies that that class won't end up creating circular references below it, and thus that a modify/return type result will work sanely. Read through bug #4901 and you might be able to understand it a bit more. It took me a long time.
In Section
Seekers of Perl Wisdom
|
|