Leopold Toetsch wrote:

Leopold Toetsch wrote:

Currently one test (t/pmc/pmc_43.pasm) is failing due to wrong inheritance.

Actually not because of inheritance. The implementation of PerlUndef.logical_xor was bogus. I've fixed this and the test.

I took a look into this. Apparently, in Perl5, the result of xor'ing undef with anything is undef. I'm not suggesting that this is either right or wrong (it actually was surprising to me), but if Parrot wanted to provide this behavior, the seemingly obvious way for this to be coded would be for PerlUndef to have the following:


    void logical_xor (PMC* value,  PMC* dest) {
MMD_DEFAULT: {
            VTABLE_set_pmc(INTERP, dest, SELF);
    }

Unfortunately, this does not work as inheritance seems to take precedence over defaults. I think that this should be the other way around: a subclass should be able to easily override all MMD operations for a given method.

Finally, I took a look at Parrot_mmd_register_parents. This seems more complicated than it needs to be, and that is because it is only looking at the mmd table (the final results after overriding) instead of at the specific overrides (the various _temp_mmd_init arrays).

An alternate approach would be for the make process to generate a function that registers a given class into a given type slot, and code to call each parent in order (top down) to override their slots as required.

A concrete example might help:

Parrot_PerlInt_mmd_init(interp, entry) {
  const  MMD_init _temp_mmd_init[] = {...};
  Parrot_mmd_register(interp, entry, _temp_mmd_init, N_MMD_INIT);
}

followed later by the following calls:

Parrot_scalar_mdd_init(interp, entry);
Parrot_Integer_mmd_init(interp, entry);
Parrot_PerlInt_mmd_init(interp, entry);

- Sam Ruby

Reply via email to