Subject: | remove prototypes |
p() uses prototypes. Having used this in Devel::REPL exclusively for over about two years now, I'm well sick of this misfeature and its jarring admonishments that go against the flow of work. No work day passes that I don't see one of those:
Type of arg 1 to Data::Printer::p must be one of [@$%&] (not null operation)
Type of arg 1 to Data::Printer::p must be one of [@$%&] (not anonymous list ([]))
When calling p() without prototypes, please pass arguments as reference
In my opinion prototype coercion greatly diminishes the usability and usefulness of DDP.
Usefulness: it does not accept arbitrary expressions, e.g. C<'a'..'e'>.
Some - not all - of them can be rectified with by configuring C<< use_prototypes => 0 >>, so out of the box DDP has not optimal defaults. I have to take great care to carry the configuration file around to every host I want to program and debug.
Usability: when I paste in expressions, I have to be careful to wrap them in the appropriate reference constructor. Sometimes this requires a stopover in the text editor. Then I have to interpret the result and take in to account that I'm seeing an extra level of reference.
I propose for p() to accept arbitrary expressions, just like DDS::DumpLex() or any other dumper. This affects the "local configuration" feature, which changes accordingly: if the last list element is a hashref and all its keys look like DDP options, then it is removed from the list of items to be pretty-printed and accepted as local options. This heuristic is the default behaviour, but can be disabled via configuration, so that the last item is pretty-printed no matter what. That should cover all existing use cases.
A side effect of p() would be that lists are then pretty-printed with parentheses:
(
[0] "a",
[1] "b",
[2] "c",
[3] "d",
[4] "e"
)