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



On Wed, 2003-10-29 at 21:27, A. Pagaltzis wrote:
* Ross McFarland <rwmcfa1 neces com> [2003-10-29 20:57]:
accessing GObject properties as keys in the object hash sould
cool to you, $button->{label} = 'This is the text on the
button', then read on.

Not really. Typos won't be caught (not even at runtime), and it's
not subclassing friendly.

by design, i had no intentions of preventing the use of the object as a
standard hash, only providing the properties in a more perl like
fashion, hash keys. basically my response would be that if you want this
type of checking/validation use the existing get/set methods this
doesn't change them. as an added bonus if you want be able to dump the
all properties, Data::Dumper, this will allow you to do so. point taken
though, just wasn't my intention or desire.

Now if you want to AUTOLOAD for something like ->prop_label() ...

not sure what exactly you're suggesting here. i can thing of things that
could be done with AUTOLOAD, but they wouldn't have anything to do with
the object properties being hash keys. having the properties be methods
wouldn't seem very intuitive and in fact could cause  name space clashes
if/when/where properties and methods collide. 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. 

only my opinions of course. 

-rm




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