develooper Front page | perl.perl5.porters | Postings from August 2021

Re: Missing sv_setrv()

Thread Previous | Thread Next
From:
Paul "LeoNerd" Evans
Date:
August 22, 2021 17:41
Subject:
Re: Missing sv_setrv()
Message ID:
20210822184058.592ba7e0@shy.leonerd.org.uk
On Fri, 23 Jul 2021 11:50:54 +0100
"Paul \"LeoNerd\" Evans" <leonerd@leonerd.org.uk> wrote:

> I'll probably just add this to core (minus the unnecessary #ifdef),
> unless anyone has a suggestion why not.

I'm just coming back to actually writing this now, and I've encountered
a few design questions, partly from comparing the function to similar
others in perl core, and partly from looking at simplifying other bits
of code to just call this new function instead of their own internal
logic involving SvRV_set and friends:

  * Should it invoke SETMAGIC on the sv? I notice that sv_setiv() does
    not (but there's a related sv_setiv_mg() which does); similar with
    the other related ones. This feels the right shape.

  * Should it increment the refcount of the referred SV? I suspect I
    should in fact add two separate versions, sv_setrv_noinc() and
    sv_setrv_inc() to be really clear on this.

    That would lead to in total, four new macro names:
      sv_setrv_noinc()
      sv_setrv_noinc_mg()
      sv_setrv_inc()
      sv_setrv_inc_mg()
    Is this OK?

  * Should it accept ref=NULL to clear the reference? I currently think
    it shouldn't (especially because that makes sv_setrv_inc more
    awkward). But, if it did accept NULL then I could replace a few
    more bits of custom code in core with more calls to this function.

-- 
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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About