Leopold Toetsch wrote:
Sam Ruby <[EMAIL PROTECTED]> wrote:
Leopold Toetsch wrote:
2) by a distinct Bound_Meth PMC class derived from 1)
The latter is probably cleaner. Binding the object to the callable could be done e.g. by the C<set_pmc> vtable.
That's exactly how PyBoundMeth works today.
C<set_pointer> sets the pointer to the actual subroutine. C<set_pmc> sets the pointer to the "bound" object.
Great. I saw the checkin but didn't have a close look at it. So if even the interface is the same, we really should put it into the core classes.
Cool. I'd likely still subclass it to provide a get_string.
WRT implementation: I'd like to swap struct_val/pmc_val for all Sub classes. It's just cleaner but should be almost fully transparent to users of these classes.
No objection.
WRT functionality: for a call it has to shift up PMC arguments and insert the object as P5, right?
At the moment, it contains this logic. My plans are to remove the shifting and set the object into P2 / INTERP->ctx.current_object.
Notes: at the moment, every Python method call creates a bound object, and shifts PMC arguments. Removing the shifting of PMC arguments will require the insertion of an interpinfo opcode into each method.
If there were a call_method VTABLE entry and if P2 were passed into methods, all of this would be unecessary in the majority of cases.
- Sam Ruby