Re: Properties as hash keys, damn perl is cool!
- From: Emmanuele Bassi <bassi-e libero it>
- To: gtk-perl-list gnome org
- Subject: Re: Properties as hash keys, damn perl is cool!
- Date: Wed, 29 Oct 2003 23:14:41 +0100
* Ross McFarland <rwmcfa1 neces com>:
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.
First of all, this is very cool and neat stuff, and I've been thinking
just a week ago how cool and neat would have been if Perl had this
feature that other bindings (see Gtk#) do have right now. Apparently,
you've been reading my mind. :-)
I've even thought about implementing something myself, but I'm not a
Perl hacker half as good as you or muppet are. ;-)
The pros of this feature are, obviously, a more clean and
object-oriented approach to GObjects' properties.
That was the over-enthusiastic part. Now, I'll have to state the cons
that I came up with when I was thinking about exposing properties as
keys of the object's hashref: first of all, and major annoyance, this
feature could end up breaking existing code (that is also the reason
why, in PyGTK, this exposure of properties wasn't done). The other
major issue regards memory use: a button has a few properties, but a
thing like a CellRendererText has some 30+ properties, some of them bound
to other objects and not to simple scalar values; exposing all of those
properties could result in a memory hog in, for instance, a cell-data
function (where, according to my personal experience, you'll end up
modifing most of the cell rendererer's properties).
+++
In the end, I strongly suggest of keeping this feature to be explicitely
called by the programmer, or to implement a pragmatic module that does
this on developer's behalf, and not trying to be "smart", and doing this
"under the hood" of gtk2-perl.
Regards,
Emmanuele.
--
Emmanuele Bassi (Zefram) [ http://digilander.libero.it/ebassi/blog ]
GnuPG Key fingerprint = 4DD0 C90D 4070 F071 5738 08BD 8ECC DB8F A432 0FF4
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]