ここから scala の続きのブログ投稿を読んでいます。残念ながら、これは scala 2.10.0 では機能しません:
def f():Int @cps[Int,Int] = {shift { (k:Int=>Int) => k(6) } - 1}
<console>:10: error: wrong number of type arguments for util.continuations.cps, should be 1
def f():Int @cps[Int,Int] = {shift { (k:Int=>Int) => k(6) } - 1}
^
<console>:10: error: type mismatch;
found : Int @scala.util.continuations.cpsSynth
@scala.util.continuations.cpsParam[Int,Int]
required: Int
def f():Int @cps[Int,Int] = {shift { (k:Int=>Int) => k(6) } - 1}
提案されたタイプを試した場合も同じです:
def f():Int @cpsParam[Int,Int] = {shift { (k:Int=>Int) => k(6) } - 1}
<console>:4: error: type mismatch;
found : Int @scala.util.continuations.cpsSynth
@scala.util.continuations.cpsParam[Int,Int]
required: Int
object $eval {
未使用の入力パラメーターを追加しても、文句はありません。
def f2(x:Int):Int @cpsParam[Int, Int=>Int] = shift { (k:Int=>Int) => k } -1
f2: (x: Int)Int @scala.util.continuations.cpsParam[Int,Int => Int]
reset(f2(1))(0)
res12: Int = -1
なぜこれが起こっているのか説明できますか?