On 9/2/00 12:16 AM, John Tobey wrote:
> Every base's SETUP gets the same argument list? That seems highly
> undesirable from an OO-purity standpoint. Or do you have a syntax for
> member initializer lists in store for us?
I've been thinking about this too. I want some sort of decision to
save us all from playing Guess the Attribute/Constructor Syntax.
Hmmm, is it....
$obj1->new(-attr => 'value');
or
$obj2->new(Attr => 'value');
or
$obj3->new({ Attr => 'value' });
Etc.
Is it...
$obj1->set(-attr => 'value');
or
$obj2->set_attr('value');
or
$obj3->attr('value');
Etc.
If you run across an object somewhere in Perl code and you know it has a
"name" parameter, how do you get it? How do you set it? Who knows? Yeah
yeah, RTFM, but IMO there should be a "standard" mechanism for these things.
The vast majority of objects just want standard set/get/init attribute
behavior, in my experience. And "standard by convention" is not good enough
because it still forces every programmer to tediously litter his objects
with code for parsing and handling attributes in (what he hopes is) the
"standard" way.
Sure, allow all the old ways if someone wants to override the default
behavior, but the "built in" behavior should take care of the majority of
cases. Having no built-in behavior other than (evil) direct access:
$obj->{'attr'} = 'value'; # Ha ha! I know you're a hash key!
is not fun after the 500th time you've written a get/set autoloader or
"-flag => val" parser or whatever.
-John