Re: Properties as hash keys, damn perl is cool!



* Ross McFarland <rwmcfa1 neces com> [2003-10-30 04:13]:
that and i don't see the value in replacing $obj->set(foo =>
'bar'); with something like $object->foo('bar'); that isn't
more perlish, it's just a different and un-obvious way of doing
something already available. 

I would disagree it's not more Perlish. Combined setter/getters
that set the value of a property if given parameters and return
it if not are quite Perlish; for the final touch, they should
return $self as a setter. Then you can do stuff like

$obj
    ->foo(1)
    ->bar('baz')
    ->quux(answer => 42);

Lots of modules employ this style, too.

You're right that we have a potential for future collisions here
though.

-- 
Regards,
Aristotle
 
"If you can't laugh at yourself, you don't take life seriously enough."



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]