Created
July 4, 2010 18:46
-
-
Save masak/463655 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A { method foo($x, $y) { say "A"; nextsame } } | |
class B is A { multi method foo($x, $y) { say "B"; nextsame } } | |
class C is B { multi method foo($x, $y) { say "C"; nextsame } } | |
C.new.foo("OH", "HAI"); | |
# masak thinks this should print "C\nB\nA\n", because that's what it looks | |
# like it should produce, and anything other than that breaks Least Surprise. | |
# jnthn thinks there's no way it can't print anything other than | |
# "C\nB\nB\nA\n", because of the two-level dispatcher layering (one layer | |
# for C3 dispatch, and another for "these multies go together" dispatch. | |
# Because these are independent, and because B.foo and C.foo "go together" | |
# due to both being multies, B gets called a second time when the inner | |
# dispatcher runs out of candidates, and the outer one proceeds up from | |
# A to B. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment