Created
February 6, 2014 10:36
-
-
Save kmizu/8841844 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| object ImplicitParams { | |
| trait C[A] | |
| } |
This file contains hidden or 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
| object ModuleA { | |
| import ImplicitParams._ | |
| import ModuleB._ | |
| def foo[A](a: A)(implicit c: C[A]) = bar(a) | |
| } |
This file contains hidden or 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
| object ModuleB { | |
| import ImplicitParams._ | |
| def bar[A](a: A)(implicit c: C[A]): C[A] = c | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ここで、
barのimplicitな引数cの正確な型がModuleB.scalaのコンパイル時にわからないことを持って「動的ディスパッチ」と言っていいかどうか。これって単に多相関数の呼び出しがネストしたときの一般的な話では?というのが自分の見解。