[svn:parrot] r33417 - trunk/src/pmc

Patrick R. Michaud pmichaud at pobox.com
Mon Dec 1 14:42:48 UTC 2008

On Mon, Dec 01, 2008 at 02:08:09AM -0800, julianalbo at cvs.perl.org wrote:
> Log:
> fix is_same with pmc string and null and with null pmc, parrot-tickets#11
> --- trunk/src/pmc/null.pmc	(original)
> +=item C<INTVAL is_same(PMC *value)>
> +
> +Returns true if value is also a null PMC, false otherwise.
> +
> +=cut
> +
> +*/
> +    VTABLE INTVAL is_same(PMC *value) {
> +        return PMC_IS_NULL(value);
> +    }
> +
>  }

Since there's only one PMCNULL value, do we really need this
vtable entry?  And why would it do anything different from the
default, which is to compare C<value> and C<SELF> ?

In fact, naively I expect that nearly all PMCs should simply
use the default "is_same" VTABLE function, which simply returns
the result of C< value == SELF >.  It's not at all clear to me
why some of the PMCs override this default behavior.

Continuing on with the String PMC, even after the patch in r33417
we still have the case of:

    $ cat x.pir
    .sub main
        $P0 = new 'String'
        assign $P0, 'foo'
        $P1 = split ' ', 'parrot speaks your language'
        $I0 = issame $P0, $P1
        say $I0

    $ ./parrot x.pir
    get_string() not implemented in class 'ResizableStringArray'
    current instr.: 'main' pc 10 (x.pir:7)

To satisfy my curiosity I tried removing the is_same VTABLE function
from src/pmc/string.pmc entirely, and all Parrot tests still pass.
This tells me that either (1) we don't need to be checking anything
beyond the default SELF == value test, or (2) we aren't adequately
testing whatever feature the current is_same definition is trying 
to accomplish.

At this point I'll take the position that we should remove the 
special is_same VTABLE definitions for both the String and Null 
PMCs (i.e., they should simply inherit the default).


More information about the parrot-dev mailing list