develooper Front page | perl.perl5.porters | Postings from January 2018

Re: CvNAME_HEK_set() - public API?

Thread Previous | Thread Next
Father Chrysostomos
January 25, 2018 17:33
Re: CvNAME_HEK_set() - public API?
Message ID:
Paul Evans wrote:
> the chunk
> of code I copypasted from pad.c in this case is
>   if(CvNAMED(orig))
>     CvNAME_HEK_set(new, share_hek_hek(CvNAME_HEK(orig)));
>   else
>     CvGV_set(new, CvGV(orig));
> I notice that `CvNAME_HEK_set()` is available in cv.h, and feels the
> sort of macro that would be public API.
> I also notice that it doesn't work. Its definition calls
> `unshare_hek()`, which embed.h only defines inside #ifdef PERL_CORE,
> meaning it's not visible to XS users. If I simply steal the one-line
>   #define unshare_hek(a)          Perl_unshare_hek(aTHX_ a)
> then it appears to work fine, but it makes me feel cautious.

HEKs are not actually part of the API.  Defining unshare_hek like that will work, but will be fragile and may break later on.  Ideally you shouldn't have to do this, because cv_clone should do what you need.

My suggestion would be to define unshare_hek for now (which is a
hack), and then see later on if cv_clone can be modified to fit your
needs better.  Maybe we actually need a more general cv_clone_flags
function with different options.  Determining that will depend on what
you come up with in your version cv_clone, I suppose.

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