Skip to content
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

Ambiguous multisubs not throwing an exception #3638

Open
p6rt opened this issue Jan 10, 2015 · 1 comment
Open

Ambiguous multisubs not throwing an exception #3638

p6rt opened this issue Jan 10, 2015 · 1 comment
Labels
RFC Request For Comments

Comments

@p6rt
Copy link

p6rt commented Jan 10, 2015

Migrated from rt.perl.org#123577 (status was 'new')

Searchable as RT123577$

@p6rt
Copy link
Author

p6rt commented Jan 10, 2015

From @Ovid

The following code prints "Int"​:
    multi f(Int $f where * < 20) {"Int" }    multi f(Int $f where * > 0)  { "greater" };     say f(3)
I'm told that "earlier wins", but sub resolution shouldn't be ambiguous. This is even worse with roles​:
    role R1 { multi method foo(Int $f where * > 0)  { say "R1" } }    role R2 { multi method foo(Int $f where * < 10) { say "R2" } };     class C does R1 does R2 {}; C.new.foo(3)
    # prints R2
Versus (note the role consumption order)​:
    role R1 { multi method foo(Int $f where * > 0)  { say "R1" } }    role R2 { multi method foo(Int $f where * < 10) { say "R2" } };     class C does R2 does R1 {}; C.new.foo(3)
    # prints R1
Now the order of role composition is important, but avoiding that is part of the reason roles were invented in the first place (http://scg.unibe.ch/archive/papers/Scha02cTraitsModel.pdf). It's a potential maintenance nightmare. Some developer, trying to make the code more readable, sorts the roles alphabetically and breaks the code via mysterious action at a distance.
This is perl6 version 2014.12 built on MoarVM version 2014.12

Best,Ovid--
IT consulting, training, international recruiting
       http://www.allaroundtheworld.fr/.
Buy my book! - http://bit.ly/beginning_perl
Live and work overseas - http://www.overseas-exile.com/

@p6rt p6rt added the RFC Request For Comments label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC Request For Comments
Projects
None yet
Development

No branches or pull requests

1 participant