views:

496

answers:

1

Scala 2.8.0.RC1 includes the continuations plugin on trunk for the first time, but the details of how to get access to the shift and reset operations have changed from previous releases, so it's difficult to follow the blog entries and SO answers out there that talk about continuations but were written for previous versions.

See also http://stackoverflow.com/questions/1512930/what-are-scala-continuations-and-why-use-them which talks about what you might want to do with shift and reset once you have them.

+3  A: 

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.

Seth Tisue
Note that if you are using the eclipse plugin, put "continuations:enable" in the "P" compiler preferences, and also be sure to clear out the "Xpluginsdir" pref, as the default values in there seem to interfere with using the continuations plugin.
Mitch Blevins
Information for sbt users on enabling the plugin is here: http://groups.google.com/group/simple-build-tool/browse_thread/thread/523fbbce5f67ddfe
Seth Tisue
Information for maven users on enabling the plugin is here: http://scala-programming-language.1934581.n4.nabble.com/scala-using-continuations-plugin-with-2-8-0-RC1-and-maven-td2065949.html#a2065949
Seth Tisue