On Mon, Aug 16, 2010 at 3:03 PM, David H. Adler <[email protected]> wrote:
> Given the code:
>
> use v6;
>
> sub speakhash (*%hash) {
> say "%hash{}";
> }
>
> speakhash(1, 2, 3, 4, 5, 6);
>
> I get the error:
>
> Too many positional parameters passed; got 6 but expected 0
> in 'speakhash' at line 3:slurphash.p6
> in main program body at line 7:slurphash.p6
>
> According to the UsingPerl6 draft document, "*%hash slurps all the
> remaining unbound named arguments into a hash."
The key here is "named" arguments; You've invoked the speakhash sub
with positional args.
Try this:
sub speakhash (*%hash) {
say %hash.perl;
}
speakhash(a => 1, b => 2, c => 3, d => 4, e => 5, f => 6);
> So, it looks to me as though the arguments given to the speakhash()
> subroutine should be slurped into %hash. Regardless, it strikes me as
> odd that Rakudo* seems to think that the subroutine should expect *0*
> arguments.
The error message is potentially confusing, yes.
> So... clearly there's a problem here, but I'm not sure if it's with
> Rakudo* or with my thinking. :-)
>
> Any thoughts on this matter would be appreciated.
>
> many thanks,
>
> dha
>
> --
> David H. Adler - <[email protected]> - http://www.panix.com/~dha/
> Why *isn't* there a Widget::Gonzo module?
>
--
Will "Coke" Coleda