5 ms·
"Support for continuations. A compiler plugin will support continuations as an optional feature of Scala, using a type-directed continuation passing transform.
by wooby 17y ago
"Support for continuations. A compiler plugin will support continuations as an optional feature of Scala, using a type-directed continuation passing transform. Continuations are useful to implement advanced control constructs, for instance for asynchronous I/O, user interface event handling, or dataflow concurrency."
I didn't think continuations were possible on the JVM. Any idea how they're doing this?
- amalcon 17y ago"using a type-directed continuation passing transform." So it converts your program to continuation-passing style, which you can do in any environment if you're willing to mangle the program enough. I would not expect it to be fast.
- rcoder 17y agoMy understanding is that Scala already wraps lambdas in internal class instances with a `call` method, so I would imagine that CPS will carry a similar performance and memory hit. It certainly won't be quite as fast as idiomatic Java code, but it should be considerably faster than other non-local exit implementations that rely on exception handling to manipulate the stack.
- jcl 17y agohttp://blog.richdougherty.com/2009/02/delimited-continuations-in-scala_24.html http://blog.richdougherty.com/2009/02/delimited-continuation... It sounds like you will only be able to do continuations within Scala code, not over a call-stack that includes Java/Scala transitions. (...which is entirely feasible. After all, many interpreters for continuation-friendly languages are built on top of C, which has no continuations.)
- wooby 17y agoAs far as I understand this page, it's actually possible to implement continuations in C: http://homepage.mac.com/sigfpe/Computing/continuations.html http://homepage.mac.com/sigfpe/Computing/continuations.html
- carterschonwald 17y agoI think that the key bit is having it be type directed, so that they can have an explicit concrete representation of the stack as a datastructure that the jvm can optimize, but thats just me speculating