The Artima Developer Community
Sponsored Link

Scala Buzz
Continuations plugin for Scala 2.8 beta

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Rich Dougherty

Posts: 21
Nickname: richd
Registered: Aug, 2003

Rich Dougherty is a programmer from New Zealand.
Continuations plugin for Scala 2.8 beta Posted: Jan 21, 2010 5:10 PM
Reply to this message Reply

This post originated from an RSS feed registered with Scala Buzz by Rich Dougherty.
Original Post: Continuations plugin for Scala 2.8 beta
Feed Title: Rich Dougherty's Scala posts
Feed URL: http://blog.richdougherty.com/feeds/posts/default/-/scala?alt=rss
Feed Description: Programming with Scala.
Latest Scala Buzz Posts
Latest Scala Buzz Posts by Rich Dougherty
Latest Posts From Rich Dougherty's Scala posts

Advertisement

The first Scala 2.8 beta is due to be released soon. Unfortunately the continuations code won't be merged in time for the beta. In the meantime if you want to try out the continuations features then you'll need to build the continuations compiler plugin and support library yourself. In preparation for the beta release I thought I'd post some updated instructions for building the continuations plugin.

Building the plugin

These instructions are based on a recent beta release candidate, but they should also work fine for the actual beta. The process for building the plugin is pretty much as I described in my previous post. The only real change is that you now need to download an additional JAR from the Maven repository, because the JAR is no longer included in the standard Scala distrubtion.

First download the Scala 2.8 beta. If you want to use a newer release then you'll of course need to update the URLs.

$ wget http://www.scala-lang.org/downloads/distrib/files/scala-2.8.0.Beta1-RC8.tgz
$ tar xzf scala-2.8.0.Beta1-RC8.tgz
$ wget http://scala-tools.org/repo-releases/org/scala-lang/scala-partest/2.8.0.Beta1-RC8/scala-partest-2.8.0.Beta1-RC8.jar -O scala-2.8.0.Beta1-RC8/lib/scala-partest.jar
$ export SCALA_HOME=`pwd`/scala-2.8.0.Beta1-RC8

Next get the source for the continuations plugin.

$ svn co http://lampsvn.epfl.ch/svn-repos/scala/compiler-plugins/continuations/trunk continuations

Then build it and run the tests.

$ cd continuations
$ ANT_OPTS=-Xmx512m ant test

Compiling and running a program that uses continuations

Set an environment variable to point to the continuations code.

$ export CONT_HOME=.../continuations

Here's a short example program that uses continuations.

$ cat > example.scala
import scala.continuations.ControlContext._

object Example {
  def main(args: Array[String]) {
    reset {
      println("first")
      shift { k: (Unit => Unit) => k(k(())) }
      println("last")
    }
  }
}

To compile it you'll need to load the continuations plugin into the compiler.

$ $SCALA_HOME/bin/scalac -Xplugin:$CONT_HOME/build/pack/selectivecps-plugin.jar -classpath $CONT_HOME/build/build.library example.scala

To run it just make sure you include the continuations runtime library.

$ $SCALA_HOME/bin/scala -classpath $CONT_HOME/build/build.library:. Example
first
last
last

Enjoy!

Read: Continuations plugin for Scala 2.8 beta

Topic: Progress of Migrating AIOTrade to Scala #2 Previous Topic   Next Topic Topic: JNI + applets = pain!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use