New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wishlist: add Devel::Peek::Dump() support #13

Open
dagolden opened this Issue Aug 22, 2012 · 5 comments

Comments

Projects
None yet
2 participants
@ghost

ghost commented Aug 22, 2012

much like disassembling, it would be nice to be able to Dump variables

@rocky

This comment has been minimized.

Show comment
Hide comment
@rocky

rocky Aug 23, 2012

Owner

Thanks for the suggestion!

In commit 8fe1580 this is added under the name "info variables dump". There are already other "info variables" commands. I would like to do more on validity checking of the variable name argument, but I don't know to what extent that can be done. I don't know Devel::Peek that well, should more features be offered?

I am happy that Devel::Peek is part of Perl. I'm not happy that Devel::Peek::Dump uses print to output rather provide an interface to return a string or list of strings. Down the line I'll have to save/restore STDOUT to capture print output to a string.

Some side comments. Look at the commit for how easy it was to hack this in, although it is probably not complete and I should add a test.

commit 21f5bba fixes the help string for the "finish" command that I noticed in the demo. Again, thanks for the NY.pm work and organizing this meetup.

Owner

rocky commented Aug 23, 2012

Thanks for the suggestion!

In commit 8fe1580 this is added under the name "info variables dump". There are already other "info variables" commands. I would like to do more on validity checking of the variable name argument, but I don't know to what extent that can be done. I don't know Devel::Peek that well, should more features be offered?

I am happy that Devel::Peek is part of Perl. I'm not happy that Devel::Peek::Dump uses print to output rather provide an interface to return a string or list of strings. Down the line I'll have to save/restore STDOUT to capture print output to a string.

Some side comments. Look at the commit for how easy it was to hack this in, although it is probably not complete and I should add a test.

commit 21f5bba fixes the help string for the "finish" command that I noticed in the demo. Again, thanks for the NY.pm work and organizing this meetup.

rocky pushed a commit that referenced this issue Aug 23, 2012

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Aug 23, 2012

On Thu, Aug 23, 2012 at 12:22 AM, R. Bernstein notifications@github.comwrote:

I am happy that Devel::Peek is part of Perl. I'm not happy that *
Devel::Peek::Dump* uses print to output rather provide an interface to
return a string or list of strings. Down the line I'll have to save/restore
STDOUT to capture print output to a string.

Capture::Tiny. :-)

I suspect a patch to Devel::Peek would get accepted (though it doesn't help
older Perls).

Thanks for a great talk.

David

ghost commented Aug 23, 2012

On Thu, Aug 23, 2012 at 12:22 AM, R. Bernstein notifications@github.comwrote:

I am happy that Devel::Peek is part of Perl. I'm not happy that *
Devel::Peek::Dump* uses print to output rather provide an interface to
return a string or list of strings. Down the line I'll have to save/restore
STDOUT to capture print output to a string.

Capture::Tiny. :-)

I suspect a patch to Devel::Peek would get accepted (though it doesn't help
older Perls).

Thanks for a great talk.

David

@rocky

This comment has been minimized.

Show comment
Hide comment
@rocky

rocky Aug 24, 2012

Owner

I have not been successful in using Capture::Tiny here. It redirects output, but in the process the eval environment is not what is needed. The whole eval in the DB package is really fragile if not also ugly and contorting. For now, there is an "eval-print-save" branch that has this code, but in master, I've disabled this.

Of course running:

eval Devel::Peek::Dump(\$var); 

works if you want the output to go to STDERR. In general though, this is not what is always desired.

I'll also try to work up a patch for Devel/Peek.xs to add an optional filehandle parameter. Looking at the existing code, that seems the least invasive and backward compatible.

Owner

rocky commented Aug 24, 2012

I have not been successful in using Capture::Tiny here. It redirects output, but in the process the eval environment is not what is needed. The whole eval in the DB package is really fragile if not also ugly and contorting. For now, there is an "eval-print-save" branch that has this code, but in master, I've disabled this.

Of course running:

eval Devel::Peek::Dump(\$var); 

works if you want the output to go to STDERR. In general though, this is not what is always desired.

I'll also try to work up a patch for Devel/Peek.xs to add an optional filehandle parameter. Looking at the existing code, that seems the least invasive and backward compatible.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Aug 24, 2012

On Thu, Aug 23, 2012 at 11:01 PM, R. Bernstein notifications@github.comwrote:

I'll also try to work up a patch for Devel/Peek.xs to add an optional
filehandle parameter. Looking at the existing code that seems the least
invasive and backward compatible.

Again, this is probably something worth asking about on #p5p and seeing
what people think.

David

David Golden dagolden@cpan.org
Take back your inbox!http://www.bunchmail.com/
Twitter/IRC: @xdg

ghost commented Aug 24, 2012

On Thu, Aug 23, 2012 at 11:01 PM, R. Bernstein notifications@github.comwrote:

I'll also try to work up a patch for Devel/Peek.xs to add an optional
filehandle parameter. Looking at the existing code that seems the least
invasive and backward compatible.

Again, this is probably something worth asking about on #p5p and seeing
what people think.

David

David Golden dagolden@cpan.org
Take back your inbox!http://www.bunchmail.com/
Twitter/IRC: @xdg

@rocky

This comment has been minimized.

Show comment
Hide comment
@rocky

rocky Aug 26, 2012

Owner

Ok. Done. Will wait on resolution there on Devel::Peek before adding a command.

Another thing you can do in the meantime is add a macro for this. In .treplrc:

eval use Devel::Peek
macro dump sub{ [ 'eval Devel::Peek::Dump(\\' . (shift) . ')'] }

With this, dump @ARGV will expand to eval Devel::Peek::Dump(\@ARGV)

But if you do this, be aware that there was a bug in handling macro parameters that was just fixed 2ccb9c1 . Version 0.34 will have this fix.

Owner

rocky commented Aug 26, 2012

Ok. Done. Will wait on resolution there on Devel::Peek before adding a command.

Another thing you can do in the meantime is add a macro for this. In .treplrc:

eval use Devel::Peek
macro dump sub{ [ 'eval Devel::Peek::Dump(\\' . (shift) . ')'] }

With this, dump @ARGV will expand to eval Devel::Peek::Dump(\@ARGV)

But if you do this, be aware that there was a bug in handling macro parameters that was just fixed 2ccb9c1 . Version 0.34 will have this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment