Scala 2.10.2。运行Scala中移位的异常
import util.continuations._
import concurrent.ops._
object Main {
def main(args: Array[String]) {
reset {
try {
shift { cont: (Unit => Unit) => {
spawn {
throw new Exception("blah")
cont()
}
}}
println("after shift")
} catch {
case e: Exception => println(e)
}
println("reset end")
}
}
}
给人
Cont.scala:16: error: type mismatch;
found : Unit
required: Unit @scala.util.continuations.cpsParam[Unit,Unit]
case e: Exception => println(e)
^
one error found
如果删除了try/catch块一切都很好。我仍然试图弄清楚Scala中的延续如何工作,但是这个完全避开了我。