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

Re: Missing sv_setrv()

Thread Previous | Thread Next
Paul "LeoNerd" Evans
August 22, 2021 17:41
Re: Missing sv_setrv()
Message ID:
On Fri, 23 Jul 2021 11:50:54 +0100
"Paul \"LeoNerd\" Evans" <> 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:
    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      |  |

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About