What I find missing here is documentation of the signature to use
if you want to declare "I accept an arbitrary number of named
arguments". (Like the param() methods common in Perl5 do).
Maybe it's the slurpy hash?
sub foo (*%h) {...} ?
The spec could use some clarification on this point.
Mark
I think it's already there:
Slurpy parameters follow any required or optional parameters. They are
marked by a C<*> before the parameter:
sub duplicate($n, *%flag, *@data) {...}
Named arguments are bound to the slurpy hash (C<*%flag>
in the above example). Such arguments are evaluated in scalar context.
Any remaining variadic arguments at the end of the argument list
are bound to the slurpy array (C<*@data> above) and are evaluated
in list context.
Trey
Go down one section and read "List parameters". (I agree that it's not
particularly explicit, and there probably should be a mention of it
under "Named parameters".)
A06 also says:
"A hash declaration like *%named indicates that the %named hash should
slurp up all the remaining named arguments (that is, those that aren't
bound explicitly to a specific formal parameter)."
This description should probably be copied to the Synopsis.
> Maybe it's the slurpy hash?
>
> sub foo (*%h) {...} ?
Correct.
Stuart
So would this mean zero or more" pairs of named arguments, or one or more:
sub foo (*%h)
I expected this:
sub foo (*%h) # one more pairs
sub foo (*%h?) # zero or more pairs
The answer with pugs now is different:
sub foo (*%h) # zero or more pairs
sub foo (%h, *%h), # one or more pairs
If pugs behavior is intended, I think it should be documented in the
spec, as I found unintuitive.
Mark