On Sat Jul 27 11:27:57 2013, sprout wrote: > I did not fix this bug for calls to XSUBs, because it will make > Devel::Peek less useful. Calling Dump("$x") and being able to see what > pp_stringify is return[ing] is a useful feature. > > (Here I’m referring to the original bug reported, not the newRV issue. > Calling foo("$x") allowed the foo sub to see a TARG in $_[0], such that > print \$_[0], \$_[0] would show two different addresses.) > > Currently foo("$x") will make a COW copy of the TARG if it is a Perl > sub, but pass the TARG itself if it is an XSUB. So for XS code to call > newRV on that is wrong (or what newRV does is wrong). > > I think the real solution here is to apply the fix to XSUBs (copy TARG > arguments) but modify Devel::Peek to inline itself, so that it remains > exempt. > > That way the only XS code having access to TARGs will be that which > rummages through pads. For most XS code this will just dwim. > > In fact, having Devel::Peek inline itself would be useful for seeing the > return value of substr and vec in rvalue context, something currently > not possible. Attached is a patch to get Devel::Peek to inline itself. It also allows Dump %hash and Dump @array. It breaks compatibility in that ‘@args = ($thing, 5); Dump @args’ no longer works; scalar context is applied to both arguments now, and the number of arguments is checked at compile time, rather than run time. I still think it is worth it. The patch can also be found on the sprout/peek branch. -- Father ChrysostomosThread Previous | Thread Next