Mark Stosberg wrote:
> Hello,
> 
> I think it would helpful if the spec addressed "who wins" in MMD when
> optional arguments are present.
> 
> I just submitted these failing tests for pugs which illustrate the
> issue.
> 
> not ok 11 - Arguments (a => 'b') to signatures 1. () and 2. (*%h) calls 2
> not ok 14 - Arguments () to signatures 1. (@a?) and 2. () calls 2
> not ok 15 - Arguments (<1 2 3>) to signatures 1. () and 2. (@a?) calls 2
> 
> In summary, matches that should otherwise happen are failing because
> the "optionalness".
> 
> Reference:
> http://feather.perl6.nl/syn/S12.html#Multisubs_and_Multimethods

I took a break and thought of an important further clarification for
this. The updated text is below:

== Handling Optional and Slurpy Parameters

Optional parameters need special consideration, because they represent
two options themselves: one with with the argument and one without.
Slurpy parameters have the same concern, as they can take zero or more
arguments themselves.  For each optional parameter, a case with and
without the optional parameter is considered.

Examples:

   Arguments (a => 'b') to signatures 1. () and 2. (*%h) calls 2
   Arguments (<1 2>) to signatures 1. (@a?) and 2. (@a) calls 2
   Arguments (<1 2 3>) to signatures 1. () and 2. (@a?) calls 2
   Arguments (@a) to signatures 1. (@a?) and 2. (@a) IS TIE

Note that the variant /with/ the parameter can be considered an exact
match, but but the variant /without/ it cannot be considered an exact
match. That rule makes the following example work:

   Arguments () to signatures 1. (@a?) and 2. () calls 2


Reply via email to