Subject: | Wishlist for Perl 5.20 signature compatibility: allow bare sigils |
For example:
method foo ($, $y) { ... }
This should be roughly equivalent to:
sub foo {
my $self = shift;
my $y = $_[1];
}
Note that $_[0] still exists in the @_ array but hasn't been assigned to any lexical.
Bare sigils `@` and `%` should be allowed as slurpies. This is essentially the same as a yada-yada, but in the case of `%` will die if the remaining argument list is not even-sized.
The easiest way to implement this in my experience is to interpret a bare sigil `$` as being equivalent to `$tmp`, and otherwise handle it the same as any other parameter. However, when you inline the parameter handling code into the sub, wrap it in {...} so that `$tmp` immediately goes out of scope.
That way, you can still handle things like type constraint checks, defaults, etc on the variable easily.