Reputation: 67280
What is the status of the continuations plugin in Scala 2.10; I'm slightly confused. The following setup is in the Akka 2.2-SNAPSHOT documentation:
autoCompilerPlugins := true,
libraryDependencies <+= scalaVersion {
v => compilerPlugin("org.scala-lang.plugins" % "continuations" % "2.10.0")
},
scalacOptions += "-P:continuations:enable",
First, the scalacOption
doesn't work with 2.10 anymore, and the scalaVersion
is not actually used in the library dependencies. If I naively go ahead with 2.10 and no special configurations (remove all of the above), and Akka 2.1.0:
import concurrent.ExecutionContext.Implicits.global
import akka.dataflow._
flow { "Hello world!" } onComplete println
I get an error indicating that the continuations plug-in is not enabled.
What what is the correct approach to enable continuations in Scala 2.10?
In particular: How can I drop into the sbt console
and try out the above example with flow
. It seems I also need to make sure the compiler plugin is enabled for the REPL?
EDIT: The scalacOptions
entry does work, it seems I had a typo.
Upvotes: 2
Views: 570
Reputation: 7019
With this build.sbt
:
autoCompilerPlugins := true
scalaVersion := "2.10.0"
libraryDependencies +=
compilerPlugin("org.scala-lang.plugins" % "continuations" % "2.10.0")
scalacOptions += "-P:continuations:enable"
the following continuations-only (no Akka) example works in the REPL:
scala> import scala.util.continuations._
scala> reset { val i = shift { body: (Int => Unit) => body(5);
| println("done") }; println(i) }
Upvotes: 4