(After talking about it on the phone today.) From the Parrot side, we have basically 3 binary factors: named (or not), positional (or not), and optional/required.

The unmarked case is a required parameter that can be passed as a positional argument and can't be passed as a named argument. (Perl 6 doesn't use this at all, but other languages do.)

  .param pmc param_a

The next case is a required parameter that can only be passed as a named argument, not as a positional argument. (Essentially an optimization, also used by Perl 6.)

  .param pmc param_a :named('a')

The next case is a required parameter that can be passed as either positional or named. For each positional parameter, the signature binding code first checks if there is a matching named argument before binding a positional argument to the parameter. (The necessary essential core to support the Perl 6 semantics, though Perl 6 adds dose or two of syntactic sugar on top.)

  .param pmc param_a :lookahead('a')

The logical final case, which we won't support now but could add later, can also be passed as either positional or named, but the signature binding code doesn't bother looking at named arguments until it runs out of positional arguments. This has some interest as an optimization, but we don't have a clear immediate need for it in any language, so at the moment it's unnecessary complexity and a premature optimization.


Any of these alternatives can be marked as optional. Positional parameters must come before all lookahead or named parameters. Lookahead parameters must come before all named parameters. Positional, lookahead, and named parameters must come before any slurpy parameters. And required parameters must come before all optional parameters.

Allison

Reply via email to