Set*_*sue 24 continuations scala
问题说明了一切.
(然而,多年来,如何访问shift和reset操作的细节已经发生了变化.旧的博客条目和Stack Overflow答案可能有过时的信息.)
另请参阅什么是Scala延续以及使用它们的原因?其中谈到你可能想用做什么shift和reset一旦你有他们.
Set*_*sue 29
斯卡拉2.11
最简单的方法是使用sbt:
scalaVersion := "2.11.6"
autoCompilerPlugins := true
addCompilerPlugin(
"org.scala-lang.plugins" % "scala-continuations-plugin_2.11.6" % "1.0.2")
libraryDependencies +=
"org.scala-lang.plugins" %% "scala-continuations-library" % "1.0.2"
scalacOptions += "-P:continuations:enable"
Run Code Online (Sandbox Code Playgroud)
在你的代码(或REPL)中,做 import scala.util.continuations._
您现在可以使用shift并reset掌握您的内容.
Scala 2.8,2.9,2.10的历史信息
你必须用-P:continuations:enable旗子开始scala(或scalac).
在你的代码中,做 import scala.util.continuations._
您现在可以使用shift并reset掌握您的内容.
如果您正在使用SBT 0.7,看到https://groups.google.com/forum/#!topic/simple-build-tool/Uj-7zl9n3f4
如果您使用的是sbt 0.11+,请访问https://gist.github.com/1302944
如果您正在使用maven,请参阅http://scala-programming-language.1934581.n4.nabble.com/scala-using-continuations-plugin-with-2-8-0-RC1-and-maven-td2065949. HTML#a2065949
非SBT解决方案:
scala -Xpluginsdir /.../scala/lib/ -P:continuations:enable
Run Code Online (Sandbox Code Playgroud)
适用于scala 2.11.6,但插件/库表示它将不再包含在Scala 2.12中