Skip to content

Instantly share code, notes, and snippets.

Created July 22, 2011 15:31
Show Gist options
  • Save anonymous/1099680 to your computer and use it in GitHub Desktop.
Save anonymous/1099680 to your computer and use it in GitHub Desktop.
import util.continuations._
import collection.mutable.Map
object Goto {
val m = Map[Symbol, (Unit => Unit)]()
def label(s: Symbol) = shift{ k: (Unit => Unit) => m(s) = k; k() }
def goto(s: Symbol) = m(s)()
}
object GotoDemo extends App {
import Goto._
reset {
var i = 0
label('foo)
println(i)
i += 1
if (i < 10) goto('foo)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment