Perl: the Markov chain saw | |
PerlMonks |
Re: Should I use Fields, InsideOuts, or Properties?by mugwumpjism (Hermit) |
on Jul 06, 2005 at 22:24 UTC ( [id://472955]=note: print w/replies, xml ) | Need Help?? |
As others may have pointed out, the problem with pseudohashes is that if you do ever want to override what happens when a property is retrieved or set, you need to use tie. Class::Tangram has been designed with OO considerations like this in mind. With Class::Tangram, accessing properties becomes method calls; you don't worry about spelling hash properties wrong, because when you define extra accessors and mutators, you may call the generated ones via ::SUPER;
Note that the set_b method would have been called regardless of whether you called it directly, or used the alternate ways to set the attribute;
This is all achieved without ugly AUTOLOAD kludges.
In Section
Seekers of Perl Wisdom
|
|