Re: Magic-v2, Clone, and a possible `sv_clone` API function
[email protected] (Leon Timmermans) Fri, 5 Jun 2026 18:17:55 +0200
| Newsgroups | perl.perl5.porters |
|---|---|
| Message-ID | <CAHhgV8hdi2ohXG_3D16vqocvS2J9hbuAgw=pDrk0LQ36+4HF-Q@mail.gmail.com> |
On Thu, Jun 4, 2026 at 3:54 PM Paul "LeoNerd" Evans <[email protected]> wrote: > I've been looking around CPAN for possible modules that might break > with some of the new "Magic v2" things I am lining up for next > development cycle. Originally I was looking for things that might get > upset if we start removing any of the internal v1 magic types, and I > encountered the Clone module - because it has a comment mentioning > PERL_MAGIC_arylen. While this itself is just a comment, on a further > reading of the code in that module it looks like it's actually > concerned quite closely with a lot of the details of how Magic (v1) > currently works. This code wouldn't cope well with v2 Magic structures. > > My first thought for thinking about Magic-v2 is that a lot of the code > would need quite a bit of editing and adjusting. > > Looking around CPAN more I also see that the code has basically been > copy-pasted into at least two other dists; Clone-AsUTF8Bytes and > Class-XSConstructor. This starts to suggest that actually, rather than > living in a CPAN module, this sort of "sv_clone" API function ought to > exist at the core perl level itself. That way, it would be able to do > the right thing with a new version of Magic, or any other newer > behaviours that get added. > > (While I'm there I notice it also doesn't handle SVt_PVOBJ, the new > "object" SV type that was added in Perl 5.38 as part of the `class` > feature, so that too would want to be looked at). > > Perhaps between us we can manage to find a good solution here. > > -- > Paul "LeoNerd" Evans I can't help noticing that this sv_clone is almost the same thing as sv_dup (or probably sv_dup_inc), except that the new value doesn't live in a different interpreter. Leon