Subject: | useless use of prototypes |
P uses prototypes in several places but only where they're ignored (with the exception of Pe).
Example 1:
sub ($$) { $_[1] && q{%s} },
sub ($$) { 1==length($_[0]) && q{'%s'}},
sub ($$) { $_[0] =~ /^[+-]?\d*\.\d*$/ && q{%.2f}},
sub ($$) { 1 && q{"%s"}} ];
These are all anonymous coderefs dispatched at runtime. The ($$) prototypes have no effect.
Example 2:
GLOB => \&{sub(){'<*='.<$p>.'>'}},
IO => \&{sub(){ '<='.<$p>.'>'}},
SCALAR=> \&{sub(){ $pkg.'\\' . Px($$_, $lvl).' ' }},
ARRAY => \&{sub(){ $pkg."[".
(join ', ', map{ Px($_, $lvl) } @$p ) ."]" }},
HASH => \&{sub(){ $pkg.'{' . ( join ', ', @{[
map { Px($_, $lvl, 1) . '=>'. Px($p->{$_}, $lvl,0) }
keys %$p]} ) . '}' }},);
Same problem as above but with additional weirdness: Why is there \&{ ... } wrapped around all of these? It does effectively nothing and it's not even consistent with the block of subs further up.
Example 3:
sub P(@) {
sub Pa(@) {
sub Pea(@) {
sub Pae(@) {
Subroutines take lists by default. The (@) prototype is equivalent to no prototype at all.
Example 4:
sub ops($) {
According to the documentation this is a method (i.e. dispatched at runtime), so the prototype is ignored. (If it wasn't ignored, the code wouldn't work because ops takes 2 arguments.)