# New Ticket Created by  "Alek Storm" 
# Please include the string:  [perl #41364]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=41364 >


This patch allows object vtable method overrides for find_method, get_attr,
get_attr, get_attr_str, set_attr, set_attr_str, and get_class.  Now these
can be overridden in PIR using the :vtable flag or prefixing their
respective names with "__".  It affects src/pmc/parrotobject.pmc and
src/ops/object.ops.  Like the other vtable functions, the code searches the
class' vtable namespace and its own namespace for overrides, and returns the
result of executing the method if found.  If not, it executes the class'
default behavior.  For find_method, I had to modify the callmethod,
callmethodcc, and tailcallmethod opcodes by moving code that updated the
interpreter's knowledge of the currently executing sub to after the call to
VTABLE_find_method.

Following the form of the other vtable methods in parrotobject.pmc, the code
to look up and execute a vtable override is duplicated, presumably for
speed, but since it's quite a lot of duplication, could we move the bulk of
the code to a separate function, possibly a modified
find_vtable_override_byname in src/objects.c?  If yes, I'd be happy to write
a patch to do so.  Also, though this is more of a language design question,
shouldn't we deprecate the double-underscore method of overriding, since we
now have the :vtable flag?

This is my first patch...ever, so sorry if I'm being a bit long-winded; I
just want to provide as much information as possible.

Thanks,
Alek Storm

Attachment: vtable.patch
Description: Binary data

Reply via email to