On Tue, 24 Jan 2023 16:58:10 +0000 "Paul \"LeoNerd\" Evans" <leonerd@leonerd.org.uk> wrote: > Perhaps it could be solved by a dual-life-capable "overload::v2" which > is shipped by newer perls and can be CPAN shimmed around older ones: > > use overload::v2 > nomethod => sub ($self, $ctx, @args) { ... }; Having discussed this more in the PSC meeting, this feels like probably the best way forward actually. Bikeshedding needs to happen on exactly what the module name should be, but overall this feels best. A new module that can be shipped with core perl but also live on CPAN dual-life for older perls. It would act as a little shim around the calling-convention of the callbacks, adapting them all to a newer better shape, whereby the arg shape is always of that form: ($self, $ctx, @args) where $ctx stores a standard "overloading context" object having some methods to carry things like the op name and the swapped flag, and @args contains just everything else that would have been visible as perl-level arguments. So unops see nothing else there, binops see $other, and new stuff like substr or whatever would see the other values. The context being an object with methods on it makes a much easier place to attach other information in future, as new named methods can easily be added to it. -- Paul "LeoNerd" Evans leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/Thread Previous | Thread Next