Created
December 29, 2010 15:36
-
-
Save bseibold/758638 to your computer and use it in GitHub Desktop.
reimplementation of scala.util.control.Breaks using Scala 2.8 Continuations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Breaks { | |
import scala.util.continuations.{reset,shift} | |
def breakable = reset[Unit,Unit] _ | |
def break = shift { k: (Unit => Unit) => () } | |
} | |
object CPSBreaks extends Application with Breaks { | |
breakable { | |
println("1") | |
breakable { | |
println("2") | |
break | |
println("3") | |
} | |
println("4") | |
break | |
println("5") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
compile with
scalac -P:continuations:enable