How do I enable continuations in Scala?

前端 未结 2 530
时光取名叫无心
时光取名叫无心 2020-12-08 10:44

Question says it all.

(Yet, the details of how to get access to the shift and reset operations has changed over the years. Old blog entries

相关标签:
2条回答
  • 2020-12-08 11:08

    Scala 2.11

    The easiest way is to use 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"
    

    In your code (or the REPL), do import scala.util.continuations._

    You can now use shift and reset to your heart's content.

    historical information for Scala 2.8, 2.9, 2.10

    You have to start scala (or scalac) with the -P:continuations:enable flag.

    In your code, do import scala.util.continuations._

    You can now use shift and reset to your heart's content.

    If you're using sbt 0.7, see https://groups.google.com/forum/#!topic/simple-build-tool/Uj-7zl9n3f4

    If you're using sbt 0.11+, see https://gist.github.com/1302944

    If you're using maven, see http://scala-programming-language.1934581.n4.nabble.com/scala-using-continuations-plugin-with-2-8-0-RC1-and-maven-td2065949.html#a2065949

    0 讨论(0)
  • 2020-12-08 11:12

    Non SBT solution:

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

    Works on scala 2.11.6, but the plugin/library said that it will no longer be included with Scala 2.12

    0 讨论(0)
提交回复
热议问题