-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
multi sub with/out named parameters, which selected? #3239
Comments
From @lizmat[13:18:06] <lizmat> r: multi sub a ($a) { say "without named" }; multi sub a ($a, :$foo) { say "with named" }; a("bar") # bug or feature ?? |
From @lizmatOn Sep 21, 2013, at 1:28 PM, Elizabeth Mattijsen (via RT) <perl6-bugs-followup@perl.org> wrote:
Additionally: [13:27:02] colomon goes looking in roast |
From @jnthnOn Sat Sep 21 04:28:25 2013, elizabeth wrote:
Named parameters do not participate in multi-dispatch in the same way that positional parameters do. Of note, the presence of named parameters works the same way that `where` clauses and sub-signatures do: they serve as an additional constraint to be met. All else being equal with the positionals, this constraint makes the candidate with nameds therefore narrower, and thus considered first and at a separate level to the other candidate with no named args. Since the candidate then goes on to match (because the named parameter is optional), it is picked. Since it is narrower, there is no ambiguity with the candidate without a named parameter. Making the named parameter required would, of course, reject the candidate. That's how most trait_mod dispatches work. A test covering this is now in S06-multi/positional-vs-named.t. |
The RT System itself - Status changed from 'new' to 'open' |
@jnthn - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#119929 (status was 'resolved')
Searchable as RT119929$
The text was updated successfully, but these errors were encountered: