P is for Practical | |
PerlMonks |
Re: Why breaking can() is acceptableby hardburn (Abbot) |
on Apr 06, 2004 at 13:57 UTC ( [id://342922]=note: print w/replies, xml ) | Need Help?? |
I'd prefer that people stop using AUTOLOAD when they don't need to. Specifically:
The actual code could be more complex, such as checking $AUTOLOAD against a list of allowed attributes, but the idea of runtime handling of accessors/mutators is the same. If you must have autogenerated accessors/mutators, please use symbol table manipulation instead if at all possible:
This is faster, is as memory-efficient as things get around Perl, and (IIRC) doesn't break can. Overall, it's even better to avoid spreading accessors/mutators all over your class design in the first place, but that's a seperate issue. I understand the above isn't the only use of AUTOLOAD, but it's by far the most common. So if you're doing that, please stop and look for alternatives. Or better, fix your class design. ---- Note: All code is untested, unless otherwise stated
In Section
Meditations
|
|