Re: Gtk2::Ex::Simple::(List|Tree)
- From: muppet <scott asofyet org>
- To: gtk-perl mailing list <gtk-perl-list gnome org>
- Subject: Re: Gtk2::Ex::Simple::(List|Tree)
- Date: Thu, 28 Oct 2004 08:40:29 -0400
On Oct 28, 2004, at 4:48 AM, Vincent LADEUIL wrote:
The missing bits, again :o) I search for that, but failed :-/
[snip]
...and the missing link ! Ok, things are clear now (did I say
that before ? :o)
[snip]
Enlightment !
do you have suggestions for where or how this should be explained in
the documentation? i think i am too familiar with it to understand
fully how to explain it to the uninitiated -- at least, our current
docs reflect that.
sub new {
my ($class, $something) = @_;
# we can't do $class->new(), because we're overriding that.
Don't get that >-/ Did you mean you can't do
$class->new($something) or just that you had added a parameter ?
perl method lookup is done purely at runtime, *after* the compile
phase, and is done purely on name, not parameters (as in C++). so in
Foo::bar(), a call to Foo::bar() will resolve to the exact same
function -- you'll call yourself indefinitely. Foo::SUPER::bar() will
skip Foo::bar() while looking through @ISA for bar(), but i explained
next why i decided not to do that.
# we could do $class->SUPER::new() if we knew its call
signature.
# instead, i'll go straight to Glib::Object::new, because i know
# it will call each INIT_INSTANCE in the ancestry to initialize
# the object properly.
I'm sure I had already read that comment somewhere, I searched
for it whereever I can think of, Gtk2 doc, tutorial, examples,
can't put my finger on it ! Thanks so much :o)
i would've sworn that was mentioned in either
http://gtk2-perl.sourceforge.net/doc/pod/Glib/Object/Subclass.html or
http://gtk2-perl.sourceforge.net/doc/subclassing_widgets_in_perl.html ,
but apparently i was wrong; it seems to be assumed or inferred. it is
explained in the gtk+ documentation, but i doubt many perl programmers
will read about the guts of doing OO in C. ;-)
But it means, that it works for only one level of perl
inheritance isn't it ?
GObject only allows single inheritance; that means one parent at a
time, e.g., only one GObject in @ISA; GObject uses Interfaces in place
of multiple inheritance, but the perl bindings just use perl's @ISA.
you can, however, derive a new perl gobject from a perl-derived
gobject; the Glib test suite verifies this. everything is based on
package names, and the fact that INIT_INSTANCE and friend are called
from C when g_object_new() walks the ancestry.
wow, that's not very clear. sorry.
--
Without treatment, a common cold will last about seven days.
With treatment, it will last about a week.
-- conventional wisdom
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]