Matt Diephouse wrote:

It looks like the PMC variant is correct in this case, because Object
isn't actually a class. There's a class flag for PMCs that sets
whether or not they are a class and Object doesn't have this set.

When you call the PMC variant of isa, it calls Parrot_object_isa, and
that has this code:

   /* if this is not a class */
   if (!PObj_is_class_TEST(pmc)) {
       pmc = VTABLE_get_class(interp, pmc);
   }

So since Object isn't a class, it calls the get_class vtable and gets
the Class pmc. It then tests the object to see if it's a Class, which
it obviously isn't.

You should always get the same answer from the 'isa' opcode, whether you pass in a string or a PMC. In this case, object.pmc should override the 'isa' vtable method to delegate the lookup to the object's class. (ParrotObject.pmc inherits an overridden 'isa' from ParrotClass.pmc.)

Ultimately, both variants of the 'isa' opcode should call the vtable 'isa' (preserving encapsulation, allowing vtable overriding, etc.) This means the vtable isa needs to be able to handle keyed lookup. (Unless we reverse the decision of RT#39045.)

An object should never report that it 'isa' Object, it should only report an 'isa' relationship to the classes it inherited from. (Different HLLs will have different notional hierarchies, and we don't want Parrot's low-level implementation details to be visible in the mix.)

Allison

Reply via email to