Finding out the name of PL_compcv early in compilation
[email protected] ("Paul \"LeoNerd\" Evans") Tue, 24 Mar 2026 15:49:55 +0000
| Newsgroups | perl.perl5.porters |
|---|---|
| Message-ID | <[email protected]> |
A question on inner details, for folks familiar with the internals of op.c and friends... After you have called newATTRSUB() or similar, the newly-created CV most likely has either a CvNAME_HEK or a CvGV, on which you can find out the CV's name. But this is only created and set by newATTRSUB() itself, and isn't available at any earlier time during parsing the sub. In particular, you can't find out the name of the sub while building the optree or anything like that, when given only the value of PL_compcv. I notice that newATTRSUB() creates the name HEK or GV only from information in the nameop, which was available in the parser much earlier. In fact, init_named_cv() could have set it even. Does anyone know why it is deferred so late? For my attributes-v2 branch, I would find it very useful to get access to the name HEK or GV from out of PL_compcv, or at least by some other similar method of access, when handling the early parse-time attributes. I'm considering looking at just moving the code out of newATTRSUB() into init_named_cv() to do this, but there's a lot of long twisty cases involving trying to lazily reuse a GV or name HEK if an existing one is there, and not break pointers here there and everywhere. It's a twisty and subtle piece of logic, so it'll take me a while to really understand why it's currently shaped like that. Does anyone have any insight into it before I start? -- Paul "LeoNerd" Evans [email protected] http://www.leonerd.org.uk/ | https://metacpan.org/author/PEVANS