Re: Missing "av_splice()" function - API design questions
[email protected] ("Paul \"LeoNerd\" Evans") Mon, 1 Jun 2026 16:25:57 +0100
| Newsgroups | perl.perl5.porters |
|---|---|
| Message-ID | <[email protected]> |
On Fri, 19 Jul 2024 10:32:08 +0100 "Paul \"LeoNerd\" Evans" <[email protected]> wrote: > On Thu, 18 Jul 2024 15:56:28 -0400 > Michael Conrad <[email protected]> wrote: > > > How about: > ... > > Size_t av_splice(AV *av, Size_t idx, Size_t delcount, Size_t > > inscount, SV **sv_in, SV **sv_out); > > Mmm, the more I look at that the more I quite like it. Yes. After Quite Some Time [tm] I have finally got around to actually writing some code. For now I've named it with a "_simple" suffix because it specifically doesn't handle tied arrays (in common with a lot of the other av_*_simple API functions). Currently sitting in a draft PR, awaiting some further thoughts on a few things: https://github.com/Perl/perl5/pull/24451 One further thought being: Flags for how to deal with refcount issues (among other). Were I to start this afresh as a new API, I'd probably have a few sets of flag constants (some of which might be zero): * Flags for how to handle added items: PERL_INSERT_UNCHANGED = 0 -- insert pointer as-is PERL_INSERT_REF -- insert SvREFCNT_inc PERL_INSERT_SVCOPY -- insert newSVsv * Flags for how to handle deleted items: PERL_DELETE_UNCHANGED = 0 -- do nothing PERL_DELETE_UNREF -- do SvREFCNT_dec PERL_DELETE_MORTALIZE -- do SAVEFREESV() Those could apply to all sorts of APIs, not just this particular one. Mmmm... -- Paul "LeoNerd" Evans [email protected] http://www.leonerd.org.uk/ | https://metacpan.org/author/PEVANS