Uses for Scala continuations
continuations, scala
Solution
I'm using this to turn asynchronous functions of the form `def func(...)(followup: Result => Unit): Unit` so that instead of writing
foo(args){result1 =>
bar(result1){result2 =>
car(result2) {result3 =>
//etc.
}
}
}
you can write
val result1 = foo(args)
val result2 = bar(result1)
val result3 = car(result2)
or
car(bar(foo(args)))
(note: the functions are not limited to one argument or just the use of previous results as arguments)
See http://www.tikalk.com/java/blog/asynchronous-functions-actors-and-cps
Problem
How are people using continuations on a larger and smaller scale in Scala? Are any parts of the Scala standard library written in CPS? Are there any major performance penalties in using continuations?