Stuart Cook wrote:
>On 10/10/05, Austin Hastings <[EMAIL PROTECTED]> wrote:
>
>
>>What about whitespace?
>>
>> foo (a => 42); # Note space
>>
>>Is that the first case (subcall with named arg) or the second case (sub
>>with positional pair)?
>>
>>
>
>Sub with positional pair, since the parens aren't call-parens (because
>of the space), so they protect the pair. It would probably be prudent
>to emit a warning in this case, for obvious reasons. (Actually, this
>is one of the major problems with using parens to protect pair args.)
>
>
>
So to pass a hash that has one element requires using the <c>hash</c>
keyword?
Specifically, if I say:
@args = (a => 1, get_overrides());
Then can I say
foo([EMAIL PROTECTED]);
Or will I, in the case of no overrides, get a positional pair instead of
named a =>1 ?
>>What's the most complete way to get the sub's arguments?
>>
>>That is, for a sub that takes positional, optional, named, and variadic
>>(*) arguments, what's the best mechanism for grabbing the entire call?
>>
>>
>
>As far as I know there currently *isn't* a concise way to
>capture/forward all (or some) of a sub's arguments; the closest thing
>is:
>
> sub foo([EMAIL PROTECTED], *%named) { bar([EMAIL PROTECTED], *%named) }
>
>Which is ugly and unwieldy. I believe Luke was considering some kind
>of 'unified arg-list object' which you could use to slurp and splat
>entire argument lists, like so:
>
> sub foo(*$args) { bar(*$args) }
>
>But I don't think it's been posted to the list yet.
>
>
>
It seems like positionals, if specified, should appear as pairs in
[EMAIL PROTECTED]
unless a hash is also present. That is, @_ or its replacement as the
collection-of-all-arguments-given should be a list, for positionalness,
and should include pairs when necessary.
=Austin