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 just patched mmd-draft.txt in the pugs tree to try address optionals. Here's what I came up with: == 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 () to signatures 1. (@a?) and 2. () calls 2 Arguments (<1 2 3>) to signatures 1. () and 2. (@a?) calls 2 Mark