Re: Reördering SVt_* constants; "internal" SV type
"Paul \"LeoNerd\" Evans" <[email protected]> Mon, 29 Jun 2026 23:00:58 +0100
| Newsgroups | gmane.comp.lang.perl.perl5.porters |
|---|---|
| Message-ID | <[email protected]> |
On Thu, 18 Jun 2026 14:45:20 +0200 "H.Merijn Brand" via perl5-porters <[email protected]> wrote: > I am scared it would break a lot of CPAN/XS Actually, having read them over I think a lot of your examples prove my exact point ;) For example: > DBI.xs: if (!SvROK(ref) || SvTYPE(SvRV(ref)) > SVt_PVMG) /* XXX LV */ Yup. This line here is attempting to check that `ref` is definitely a reference to a perl scalar; so it's going to reject anything that isn't ROK or anything whose RV's SvTYPE is greater than SVt_PVMG. But it therefore misses the SVt_PVLV case. In fact its author is even aware of this, having written /* XXX LV */ in the comment there (unless they did mean to write the Roman numbers 30, 53. But I doubt it ;) ) Having skim-read most of the rest of the other examples, I think every single one of them is going to fall foul of the exact issue I am trying to address here. Namely, that they will have a false positive and believe that an SVt_INVLIST is a perl scalar (when in fact it is not), and a false negative and believe that an SVt_PVLV is not a perl scalar (when in fact it is and should be treated as such). I do not believe that the simple adjustment of moving SVt_INVLIST out of that range and moving SVt_PVLV up next to SVt_PVMG is going to change the behaviour of any of these previous comparisons which were already correct, because if they were correct before they'll still be correct afterwards. However, I think it will stand a good chance of suddenly making coincidentally correct a lot of code that previously missed those two edge cases. -- Paul "LeoNerd" Evans [email protected] http://www.leonerd.org.uk/ | https://metacpan.org/author/PEVANS
signature.asc
(application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQTNysx/4iVoQ8PHpFPM3sWJmDApegUCakLrGgAKCRDM3sWJmDAp eoYzAQDE5t/M6nr8jWkQPicsDQ65QMl5xsYoGsFG1bAb6szDCwD/QnL0hz/kELCv L7PRtVgUQc5OU0uAo+CqUZJDxWvx6Qc= =Cdv3 -----END PGP SIGNATURE-----