inheritance and multidispatch

bsdz blairuk at googlemail.com
Sun Apr 26 10:49:01 UTC 2009


Hi,

Still trying to work out how Parrot should behave in the following
code: -

.sub '' :main
    $P0 = subclass 'Integer', 'FooInt'
    $P0 = new 'FooInt'
    $P0 = 10
    sub $P0, 1 # <- breakpoint here
    say $P0
.end

I notice if a break point is placed above that the VM follows the
following stack path: -

Parrot_mmd_multi_dispatch_from_c_args(interp, "i_subtract_int",
"PI", ...)
Parrot_default_i_subtract_int(interp, $P0, 1)
Parrot_Object_i_subtract_int(interp, $P0, 1)
Parrot_sub_p_ic(long* cur_opcode, interp)

What is interesting is that Parrot_Object_i_subtract_int does check
through the vtables for the parent classes, i.e. PMCProxy and Class
but doesn't search through the parent "Integer"'s vtables. Having
failed to find anything here it goes on to
Parrot_mmd_multi_dispatch_from_c_args.

Parrot_mmd_multi_dispatch_from_c_args in turn calls
Parrot_mmd_find_multi_from_sig_obj by generating a candidate_list
which is empty since it appears to only populate the list from the
namespace of the $P0 and the global namespace (see
Parrot_mmd_find_multi_from_sig_obj).

So my question is should mmd_search_by_sig_obj not only search the
namespace of $P0 but also its parents' class vtable or maybe there's
an instance of 'Integer' hidden behind $P0 (type FooInt) with a
searchable namespace? or perhaps Parrot_Object_i_subtract_int should
also search through not just PMCProxy and Class vtables but also
Integer's vtables?

I am willing to write a patch, if only I can get some direction and
someone is willing to review as well commit the patch into SVN.

I must admit I've looked through the design docs and there's not a lot
detail about method searching and inheritance internals. If this kind
of detail has not been decided yet then let me know I will stop
following this thread and move on to something more fruitful.

Cheers
Blair


More information about the parrot-dev mailing list