Support array defaults
$ perl -wle 'use Function::Parameters qw(:strict); method foo(@bar = (1,2,3)) {} main->foo()'
In method foo: array @bar can't have a default value at -e line 1.
I don't see why not. Is this an implementation or design issue?
It's a language semantics issue. How do you distinguish an empty list from an absent list?
main->foo(()) or my $n = -1; my @values = 0 .. $n; main->foo(@values) shouldn't silently use some default values.
It would be nice if we could distinguish between being passed an empty list and being passed no list at all, but we can't (can we?). That's one of the quirks of Perl's subroutines we have to live with. If you need to tell the difference between being passed no list and being passed an empty list, use an array ref. This is all how things already work. Perl programmers already know all this. Nobody writes Perl code that depends on the difference between an empty list and no list, you can't. I don't think there will be a great surprise when @foo = (1,2,3) is applied whether @foo is empty or never passed in at all.
It's exactly what they'll do anyway.
method foo(@bar) {
@bar = (1,2,3) if !@bar;
...
}
What else are they going to do?