I'm not really missing that feature, it's just a meditation about design and orthogonality.
IMHO, it would be much easier to prog if perl had more axiomatic rules instead of a bunch of special exeptional cases. Something like "if the last obligatory list @ or scalar $ in a prototype is ommitted in the code, $_ will be included instead throwing an error".
Or as more flexible approach "you can use "@_" and "$_" in prototypes to flag parameters which default to $_ if missing" ²
anyway, perl6's solution to flag these functions with a trailing . and making them methodes of an invisible $_ seems reasonable! (eg .print; .push @a;)
Cheers Rolf
(*) Must be! That's why prototype returns undef for print and split, showing they are not overridable!
DB<10> use Data::Dumper DB<11> print Dumper prototype "CORE::split" $VAR1 = undef; DB<12> print Dumper prototype "CORE::print" $VAR1 = undef; DB<13> print Dumper prototype "CORE::push" $VAR1 = '\\@@';
(²) But I don't know if it makes sense to push a global like $_ on the stack...
In reply to Re^2: why does push not default to $_? (simple)
by LanX
in thread why does push not default to $_?
by LanX
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |