in reply to Re: Answer: How can I use AUTOLOAD to magically define get and set methods for my member data?
in thread How can I use AUTOLOAD to magically define get and set methods for my member data?
To have the benefits of the auto accessors. The methods 'a1' and 'a2' are implemented 'on demand' to use the nowadays buzzword :) If you'd like to change the implementation and want to keep the behaviour of the class from the user code point of view, you just have to implement by hand the concerned accessor methods. Anyway, I also think that explicitely write which attribute should be concerned by auto accessor generation can be a good thing. Specialy to write code that don't look too magic to new readers :) Is there a way to use the 'my @attributes = qw(color speed);' method in a factorized way ?package Foo ; use base qw/AutoAccess/ ; sub new{ bless { 'a1' => undef , 'a2' =>undef } , shift ; } 1;
|
---|