Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: what does private/public data mean in Devel::Peek

by syphilis (Archbishop)
on Aug 09, 2019 at 05:19 UTC ( [id://11104212]=note: print w/replies, xml ) Need Help??


in reply to what does private/public data mean in Devel::Peek

But what does it really mean?

The POK flag indicates that the stored PV is valid and can be used.
The pPOK flag is used internally by the magic system to establish that the PV is valid.
(And similarly for "I" and "N".)

I don't know if it's still the case that one can be set without the other.
I found an example in section 4.3 of "Extending and Embedding Perl" by Jenness and Cousins that sets pPOK without setting POK - but only on perl-5.16 and perhaps (unchecked) earlier perl versions.
On perl-5.18 and later the same code sets both POK and pPOK.

Obviously there's no need for both unless they sometimes need to be set by themselves.

Here's that demo from "Extending and Embedding Perl":
C:\_32\pscrpt>type TieFoo.pm package TieFoo; sub TIESCALAR { my $obj = "foo1"; return bless(\$obj, "TieFoo"); } sub FETCH { ${ $_[0] }++; } 1; C:\_32\pscrpt>type demo.pl use Devel::Peek; use lib '.'; use TieFoo; tie $a, 'TieFoo'; print "Initial State: \n"; Dump $a; print "\nFirst Value: $a\n\n"; print "State after a FETCH: \n"; Dump $a;
On perl-5.16, the final Dump() begins:
State after a FETCH: SV = PVMG(0x1cd4f9c) at 0x1cdf054 REFCNT = 1 FLAGS = (GMG,SMG,RMG,pPOK) ...
On later versions of perl that changes to:
State after a FETCH: SV = PVMG(0x7deea8) at 0x7cbc58 REFCNT = 1 FLAGS = (GMG,SMG,RMG,POK,IsCOW,pPOK) ....
According to Jenness and Cousins, that pPOK indicates that a cached value is available (though that cached value gets overwritten with every FETCH).
Sorry - probably not much help.
Hopefully there's someone kicking around that can do better.

Cheers,
Rob

Replies are listed 'Best First'.
Re^2: what does private/public data mean in Devel::Peek
by Anonymous Monk on Aug 10, 2019 at 10:18 UTC
    Thanks Rob, I've searched perl5.30 source, there still has some parts to test pPOK flag. I guess maybe pXOK flag indicate this SV is used for perl internal. (can't see and use from outside) but since 5.18 onward, pXOK maybe desprecated, and replaced by XOK.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11104212]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-24 01:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found