develooper Front page | perl.perl5.porters | Postings from November 2014

PADNAMEs and B::Showlex

Thread Next
From:
Father Chrysostomos
Date:
November 27, 2014 21:55
Subject:
PADNAMEs and B::Showlex
Message ID:
20141127215536.627.qmail@lists-nntp.develooper.com
If a pad name is no longer an SV, then the current Showlex output will
not make sense any more:

At v5.21.6-42-g199670d:

$ perl5.21.7 -MO=Showlex -e 'my $a, our $b'
Pad of lexical names for comppadlist has 3 entries
0: SPECIAL #1 &PL_sv_undef
1: PVNV (0x7fa47302ae88) $a
2: PVMG (0x7fa47302ae70) $b
Pad of lexical values for comppadlist has 3 entries
0: SPECIAL #0 Nullsv
1: NULL (0x7fa47302aeb8)
2: NULL (0x7fa47302aee8)
-e syntax OK

At the top we show PVNV and PVMG, but pad names will be neither; nor
will there be any such distinction.

Also, concerning B::SPECIAL, I'm not sure this interface even makes
sense for SVs, though I'm not about to change that.  I just wonder
what I should do for pad names.  Currently B::SPECIAL objects, while
they represent SVs, cannot be used like B::SV objects, so you can't
say $foo->PVX if $foo is &PL_sv_yes, because it's a B::SPECIAL, not a
B::SV, and B::SPECIAL doesn't have that method.

I am introducing two special pad names, &PL_padname_undef and
&PL_padname_const.  Internally, I am trying to avoid attributing mean-
ing to the addresses of those pad names.  They just exist for effi-
ciency, but other pad names with identical contents (len == 0) would
work just as well.  (I may have a future use for that.)

Seeing that those two particular pad names are in use in Showlex out-
put might make sense.  But how should I go about this?  Should I add
more special values to the list that B::SPECIAL represents?  Or should
I add global functions to B to access them, just as we do for main_cv?
Or (maybe this is the best solution) just treat them as other pad
names the way the internals do, but have B::Showlex special-case any-
thing with len==0 and output it as 'undef' or 'const' instead of the
(blank) variable name?

The output would look like this:

Pad of lexical names for comppadlist has 3 entries
0: (0xbaff1edbead5) undef
1: (0x7fa47302ae88) $a
2: (0x7fa47302ae70) $b
Pad of lexical values for comppadlist has 3 entries
0: SPECIAL #0 Nullsv
1: NULL (0x7fa47302aeb8)
2: NULL (0x7fa47302aee8)
-e syntax OK


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