代码之家  ›  专栏  ›  技术社区  ›  Seth Tisue

如何在scala中启用延续?

  •  23
  • Seth Tisue  · 技术社区  · 16 年前

    问题说明了一切。

    (然而,如何访问 shift reset 这些年来业务发生了变化。旧日志和堆栈溢出答案可能包含过期信息。)

    也见 What are Scala continuations and why use them? 这说明你可能想做什么 转移 重置 一旦你拥有了它们。

    2 回复  |  直到 11 年前
        1
  •  29
  •   Seth Tisue    11 年前

    斯卡拉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._

    您现在可以使用 shift reset 让你心满意足。

    scala 2.8、2.9、2.10的历史信息

    你必须从scala(或scalac)开始 -P:continuations:enable 旗帜。

    在你的代码里,做 导入scala.util.continuations.。_

    您现在可以使用 转移 重置 让你心满意足。

    如果您使用的是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

        2
  •  7
  •   krrr    11 年前

    非SBT解决方案:

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

    适用于scala 2.11.6,但插件/库 said 它将不再包含在scala 2.12中

    推荐文章