-
Notifications
You must be signed in to change notification settings - Fork 81
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
show variable name as __VAR__ #74
base: main
Are you sure you want to change the base?
Conversation
Added PPI support and some tests.. |
Nice one! I've been wanting this same thing for a while now. |
I am not sure why the tests failed here.. the tests passes on my machine using perl v5.20 on Ubuntu 14.10. |
…r earlier perl versions
@hakonhagland @jayallen YES! That's a very nice feature indeed. Sorry for not reviewing this before, I'll definitely look into reviewing and merging this right after the holidays. Thanks! |
Pull request garu#74 'show variable name as __VAR__' had a dependency on the PPI module which made its inclusion in the master less atractive for the users not using the feature. By refactoring the part of the code that depended on PPI out in a separate module, only the users that would like to use the feature needs to install PPI. The code remaining in master (that does not depend on PPI) now implements a plugin hook in the write_label() sub in Data::Printer::Object. An option in the configuration file called 'caller_plugin' is used to register a caller plugin. If such a plugin is registered, write_label() will load the plugin and then call the plugin to do the generation of the label string. The refactored part of garu#74 that depends on PPI has been included in the module Data::Printer::Plugin::Caller::PPI (currently on Github).
Pull request garu#74 'show variable name as __VAR__' had a dependency on the PPI module which made its inclusion in the master less atractive for the users not using the feature. By refactoring the part of the code that depended on PPI out in a separate module, only the users that would like to use the feature needs to install PPI. The code remaining in master (that does not depend on PPI) now implements a plugin hook in the write_label() sub in Data::Printer::Object. An option in the configuration file called 'caller_plugin' is used to register a caller plugin. If such a plugin is registered, write_label() will load the plugin and then call the plugin to do the generation of the label string. The refactored part of garu#74 that depends on PPI has been included in the module Data::Printer::Plugin::Caller::PPI (currently on Github).
How about using PadWalker? Data::Dumper::Names and Data::Dump::Streamer both do this, though they are both really old. |
@grr Yes I have considered those also, see https://github.com/hakonhagland/Data-Printer-Plugin-Caller-PPI/blob/b8d9eb2ec5ad2c5a9d6addc5a2f7cf91365b1f4d/lib/Data/Printer/Plugin/Caller/PPI/Parser.pm#L21 |
Pull request garu#74 'show variable name as __VAR__' had a dependency on the PPI module which made its inclusion in the master less atractive for the users not using the feature. By refactoring the part of the code that depended on PPI out in a separate module, only the users that would like to use the feature needs to install PPI. The code remaining in master (that does not depend on PPI) now implements a plugin hook in the write_label() sub in Data::Printer::Object. An option in the configuration file called 'caller_plugin' is used to register a caller plugin. If such a plugin is registered, write_label() will load the plugin and then call the plugin to do the generation of the label string. The refactored part of garu#74 that depends on PPI has been included in the module Data::Printer::Plugin::Caller::PPI (currently on Github).
Pull request garu#74 'show variable name as __VAR__' had a dependency on the PPI module which made its inclusion in the master less atractive for the users not using the feature. By refactoring the part of the code that depended on PPI out in a separate module, only the users that would like to use the feature needs to install PPI. The code remaining in master (that does not depend on PPI) now implements a plugin hook in the write_label() sub in Data::Printer::Object. An option in the configuration file called 'caller_plugin' is used to register a caller plugin. If such a plugin is registered, write_label() will load the plugin and then call the plugin to do the generation of the label string. The refactored part of garu#74 that depends on PPI has been included in the module Data::Printer::Plugin::Caller::PPI (currently on Github).
Hi guys!
Background: It could be useful to have the original variable name included in the output from the
p
command.When I debug a program I often have many
p
statements following each other.In order to easily see which output belongs to which variable, it would be nice if I could type:
with output:
$var = 2
. I would like to avoid repeating myself like:To me, this seems to be a difficult problem, that would involve parsing Perl code and probably should be done using the
PPI
module for parsing. However, my first strategy for building a solution to this was to get started somehow :-) something is better than nothing.So this pull request is indeed a very crude first attempt, and I hope it will be accepted so it could be gradually improved with time :-)