On Fri, 20 Aug 2021 11:55:00 +0100 "Paul \"LeoNerd\" Evans" <leonerd@leonerd.org.uk> wrote: > I propose adding an API function > > BOOL sv_numeq(SV *left, SV *right); > > to cover this. > Update: here's an initial attempt, including docs and XS::APItests: https://github.com/leonerd/perl5/tree/sv_numeq Thinking further about this, I think I'd like to define a new SV_* flag to request that the function also perform operator overloading. This new sv_numeq() would recognise that flag, and I'd also add support to the existing sv_eq(). (Which, is stringy. In hindsight it should have been named sv_streq(), but too late now (unless we rename it maybe?)) Perhaps it would be named something like `SV_TRYAMAGIC`. Or maybe the less cryptic `SV_OVERLOAD` (though we already have an unrelated flag, `SV_SKIP_OVERLOAD` which the various sv_2Xv_flags() functions all take). `SV_OVERLOAD` would be nice, except it's a bit messy having some _flags()-like functions that do overloading by default and have a flag to tell them not to, vs. other flagsy functions that don't but take a flag to tell them to. Unless..... Maybe I can solve all of these issues in one go, by making a new sv_streq_flags() which does overload by default, and put that behaviour in my new sv_numeq_flags() as well, then these functions can all respond to the same SV_SKIP_OVERLOAD flag in the same way. Then sv_eq() and sv_eq_flags() become wrappers of sv_streq_flags() which do pass the SV_SKIP_OVERLOAD flag. I think it would be nice to do overload by default as that's generally "the nice thing to do", and a flag to turn it off for specific circumstances. Thoughts? -- 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