Patrick R. Michaud wrote:
Is it possible to use __set_pmc_keyed(_int|_str)? to detect when a PMC object is being subscripted with an integer versus a string argument?
It wasn't until r9445. The problem was that classes/default.pmc has fallback methods that create PMC keys. Unfortunately we sometimes need these default methods in custom classes too, but in this case it's clearly wrong.
I've now special-cased the *_keyed_int methods, to first look for a user function and then use the fallback in default.pmc, if no user method exists.
Please note that this works only for the *keyed_int methods. The *keyed_str methods are not accessible from the opcode level, these always call the 'pmc' _keyed variant (w/o suffix). See also the added test in t/pmc/object_meths.t
I've also tried variations of @MULTI
Multis work only for real sub objects and would need some support inside classes/delegate.pmc (where the actual method dispatch is located). But as plain vtable methods aren't NCI objects, but plain C functions, we could have a mixture of PMCs and C functions, which would be a mess.
OTOH infix MMD functions are created as NCI objects and can be used with MMD.
Thanks in advance, Pm
leo