P5P:
I'm really torn on this.
On one hand I really want a better debug print in Perl core, but on the other hand the syntax and some of the limitations of Data::Printer are less than ideal.
I fully support adding some better debug style printing to core. I could probably even be convinced to support Data::Printer, but I have some concerns. I always approach Perl things from the eyes of a novice (probably because I still am a novice) and I see some simple short comings:
my $x = 3;I understand that Data::Printer is extremely powerful and does a bunch of amazing things... but for simple novice-style use cases it's going to be very confusing if I can't be used for simple things.
I do like that it:
- Scottchiefbaker
P5P:
I'm really torn on this.
On one hand I really want a better debug print in Perl core, but on the other hand the syntax and some of the limitations of Data::Printer are less than ideal.
I fully support adding some better debug style printing to core. I could probably even be convinced to support Data::Printer, but I have some concerns. I always approach Perl things from the eyes of a novice (probably because I still am a novice) and I see some simple short comings:
my $x = 3;
my $y = 4;
p($x); # Ok
p($x, $y); # Error?
p($x * $y); # Error?
p([$x, $y]); # Error?
p("$x - $y"); # Error?
p("debug"); # Error?
I understand that Data::Printer is extremely powerful and does a bunch of amazing things... but for simple novice-style use cases it's going to be very confusing if I can't be used for simple things.
I do like that it:
- Color output is great as it really helps readability
- Auto sorts hash keys to be in alphabetic order
- Aligns all the hash values on the same column for easy readability
- Is really fast
- Scottchiefbaker
I'll second this. I like Data::Printer and use it constantly, but
if you want to officially endorse it from Perl core it seems like
it ought to be a function that prints a normal expression argument
instead of requiring a variable. Less confusion for new people
that way.
Also, I'm not sure how I feel about it loading the config file.
On the one hand, I like the configurability of DDP to
custom-tailor it to produce better dumps. On the other hand, if
everyone starts leaving "use Data::Printer" lines in their modules
now because it's core, the config files could cause breakage
between environments. It would be nice if there was a stable
data-printing function whose API semantics couldn't be changed by
a config file. The other option is training/education for people
to use it while debugging and then remove it afterward, but that's
less likely when its core.
(Semi-related, the other big debugging feature missing from core perl is Carp::Always. How on earth are new developers supposed to realize that the way to get an extended stack trace is a CPAN module named "Carp::Always"???)
Maybe what would be nice is a design like Log::Any? The idea
where you have a "log producer" that indicates intent to show
something, and a "log consumer" that lets the end user decide how
to do it. For dumping, this could be like a core perl module that
does a very simplified version of Data::Printer's semantics (like
not dumping the internals of sub-objects, which generally solves
most of the infinite-dump problems) and then make an official API
where Data::Printer can install itself as a replacement of that
function. Then mention Data::Printer as the recommended upgrade
in the documentation of that function, like how IPC::Open3
recommends IPC::Run. Or, maybe like JSON where JSON loads
JSON::XS if it is installed. Maybe this dump function could even
go into builtin:: ? "show" is a nice verb that I haven't seen
many conflicts for in other modules. Having a new "show" function
available by default in perl 5.42 that automatically loads
Data::Printer if installed.... would rock!
-Mike
Hi,
On one hand I really want a better debug print in Perl core, but on the other hand the syntax and some of the limitations of Data::Printer are less than ideal.I fully support adding some better debug style printing to core. I could probably even be convinced to support Data::Printer, but I have some concerns. I always approach Perl things from the eyes of a novice (probably because I still am a novice) and I see some simple short comings:
my $x = 3;
my $y = 4;
p($x); # Ok
p($x, $y); # Error?
p($x * $y); # Error?
p([$x, $y]); # Error?
p("$x - $y"); # Error?
p("debug"); # Error?
I understand that Data::Printer is extremely powerful and does a bunch of amazing things... but for simple novice-style use cases it's going to be very confusing if I can't be used for simple things.
I see this usage is not always ideal, it would be better if Data::Printer would try harder to 'print' any data you feed it. But I guess that is fixable.
--
Michiel