DYNSUPER bust for dynamic PMCs

0 views
Skip to first unread message

Nicholas Clark

unread,
Apr 29, 2005, 9:43:52 AM4/29/05
to perl6-i...@perl.org
pmc2c.pl says:

=item C<SUPER(a,b,c)>

Calls the overridden implementation of the current method in the nearest
superclass, using the static type of C<SELF>.

=item C<DYNSUPER(a,b,c)>

As above, but uses the actual dynamic type of C<SELF>.


but for a dynamic class, if I try to use it I get errors such as:

perl5null.pmc: In function `Parrot_Perl5NULL_set_pointer_keyed_int':
perl5null.pmc:24: `enum_class_Perl5cargo_cult' undeclared (first use in this function)
perl5null.pmc:24: (Each undeclared identifier is reported only once
perl5null.pmc:24: for each function it appears in.)
make: *** [perl5null.o] Error 1

1: Perl5cargo_cult is the correct (static) superclass of Perl5NULL, so
I think that the description of DYNSUPER is inaccurate - it's actually
calling through the vtable of the defining class' parent (rather than
SUPER that goes direct), rather than what it might imply, which is going
to the superclass of the class of the invocant PMC.

2: Either way, it's bust for dynamic classes, as you can't know the type
number of the parent class at compile time.

I'm not sure what to do about either.

Nicholas Clark

Leopold Toetsch

unread,
Apr 29, 2005, 12:03:27 PM4/29/05
to Nicholas Clark, perl6-i...@perl.org
Nicholas Clark <ni...@ccl4.org> wrote:
> pmc2c.pl says:

>=item C<DYNSUPER(a,b,c)>

> As above, but uses the actual dynamic type of C<SELF>.

> but for a dynamic class, if I try to use it I get errors such as:

> perl5null.pmc: In function `Parrot_Perl5NULL_set_pointer_keyed_int':
> perl5null.pmc:24: `enum_class_Perl5cargo_cult' undeclared (first use in this function)

You could try this:

static int enum_class_Perl5cargo_cult;

pmclass Perl5NULL dynamic extends Perl5cargo_cult {

void class_init() {
enum_class_Perl5cargo_cult = pmc_type(interp, "Perl5cargo_cult");
}
...
}

leo

Leopold Toetsch

unread,
Apr 29, 2005, 2:49:16 PM4/29/05
to Nicholas Clark, perl6-i...@perl.org
Nicholas Clark <ni...@ccl4.org> wrote:

>=item C<DYNSUPER(a,b,c)>

Another note: we might as well create a C<super> vtable call as well. We
need some such (and an opcode) anyway for HLL objects.

How could/should that beast look like?

$ python
>>> help(super)
class super(object)
| super(type) -> unbound super object
| super(type, obj) -> bound super object; requires isinstance(obj, type)
| super(type, type2) -> bound super object; requires issubclass(type2, type)
| Typical use to call a cooperative superclass method:
| class C(B):
| def meth(self, arg):
| super(C, self).meth(arg)

> Nicholas Clark

leo

Reply all
Reply to author
Forward
0 new messages