пн, 17 авг. 2026 г. в 21:49, Tom Lane <[email protected]>:
> I spent some time digging through the Perl documentation and source > code, and I'm starting to have doubts about this idea of "fix it > by applying SvGETMAGIC to array/hash entries". I can't see anything > in the documentation recommending such an approach, and I don't see > any of their own code doing so either. Pretty much all their calls > to SvGETMAGIC are in functions that have been passed a scalar value > from elsewhere. So while this may work today, I'm unconvinced that > it's idiomatic or future-proof. Can you point at any production code > that is doing it this way? > > https://perldoc.perl.org/perlguts - generic C code must call the SvGETMAGIC() macro to invoke any 'get' magic if they use an SV obtained from external sources in functions that don't handle magic. See perlapi for a description of these functions. https://perldoc.perl.org/perlapi#SvGETMAGIC - This is an idiomatic way. I can search for the production code, but there are many xs modules on metacpan and everyone uses this approach, as it is described in the documentation. As an example, let's use the Encode module https://github.com/Perl/perl5/blob/c31ca2013f287840fcddf498ead9602666569966/cpan/Encode/Encode .xs#L349
