Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Calling Methods on Class PMCs

11 views
Skip to first unread message

Chromatic

unread,
Oct 8, 2006, 11:12:16 PM10/8/06
to parrot-...@perl.org
I'm experimenting with better forms of OO in PIR. I want to add a
get_parents() method on the Class PMC. Normally, I'd do something like the
attached patch, but the attached example file I use for testing shows that it
doesn't work for me.

I dug around a bit and couldn't find a reason for why it shouldn't work.

Note that I can't even call name() on a Class PMC either. Hm.

-- c

class_method.patch
class_fun.pir

Leopold Toetsch

unread,
Oct 9, 2006, 1:48:36 PM10/9/06
to perl6-i...@perl.org
Am Montag, 9. Oktober 2006 05:12 schrieb chromatic:
> I'm experimenting with better forms of OO in PIR. I want to add a
> get_parents() method on the Class PMC. Normally, I'd do something like the
> attached patch, but the attached example file I use for testing shows that
> it doesn't work for me.

You were probably looking for the C<get_mro> opcode. Your get_parents() is
only returning the immediate parent(s) of that _class_ but not the full
chain, which is in C<vtable->mro>.

See also: perldoc src/ops/pmc.ops

> I dug around a bit and couldn't find a reason for why it shouldn't work.

You are calling it on a ParrotObject, which ought to delegate the call to it's
class. But as said, you'd get only 'Child' in your case.

> Note that I can't even call name() on a Class PMC either. Hm.

As a method? You can't call any vtable function with method syntax.

See also:

http://perlcabal.org/~lt/toreview/Cfunc.pod

But there is:

inline op typeof (out STR, invar PMC) {
$1 = VTABLE_name(interpreter, $2);
goto NEXT();
}

i.e. the C<typeof> opcode is the interface to the class name.

> -- c

leo

0 new messages