Matt Diephouse (via RT) wrote:
There's no real way to set a vtable function at runtime. It's possible to use the PIR compiler to eval a new function, but there's no way to take an existing sub and add it as a vtable function[1].

Before :vtable, this operation simply meant adding the sub to the new namespace under the right name. But since that's going away, we need a new way to do things.

I suspect we need some sort of set_vtable opcode.

     set_vtable ['Foo'; 'Bar'], 'get_string', $P0

Maybe there should be set_root_vtable and set_hll_vtable variants to go along with to match the set_*global opcodes.

For classes, the 'add_method' method takes a named parameter to say whether it's a vtable function. And, vtable functions aren't stored in the namespace at all anymore, but in a data structure inside the class, so you wouldn't have 'root' and 'hll' variants. I can see potentially see adding an 'add_vtable' vtable function, parallel to add_method, add_attribute, etc.

What's the use case for modifying a low-level PMC's vtable entries at runtime? Or, are you only talking about overriding vtable functions in a class?

Allison

Reply via email to