2010-04-21 74 views

回答

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" 

在你的代码(或REPL),请import scala.util.continuations._

您现在可以使用shiftreset到你心中的内容。

斯卡拉2.8,2.9的历史信息,2.10

你必须开始与-P:continuations:enable标志斯卡拉(或scalac)。

在你的代码,做import scala.util.continuations._

您现在可以使用shiftreset你的心脏的内容。

如果您正在使用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

+4

请注意,如果您使用的是eclipse插件,请在“P”编译器偏好设置中放置“continuations:enable”,并且一定要清除“Xpluginsdir”pref,作为其中的默认值似乎会干扰使用continuations插件。为Eclipse用户提供的 – 2010-04-21 15:52:15

+0

,请参阅http://stackoverflow.com/questions/4556540/continuations-in-scala-2-8-1-and-eclipse – 2011-01-04 17:34:29

+0

谢谢米奇Blevins - 我有麻烦,直到我清除了Xpluginsdir优先。无法在其他地方找到该建议。 – Eric 2011-06-04 02:36:28

7

非SBT的解决方案:

scala -Xpluginsdir /.../scala/lib/ -P:continuations:enable 

作品上阶2.11.6,但该插件/库said,它将不再includ用Scala编辑2.12

+1

请注意,也许有人会更新插件与2.12一起工作,即使它肯定不会被捆绑。 – 2015-09-19 00:30:11