Delimited continuations

#1

There was a paper by Odersky a few years ago about continuations being supported in Scala. And I also see that they were supported in Scala 2.11 via a compiler plugin. However, it seems, I fear, that nobody is maintaining this.

Is this something anyone has considered for Scala 2.12 and higher?

BTW I have until now not been able to get continuations to work even in 2.11. There is a stackoverflow page about how to try to make them work, but it contains several contradictory pieces of advise.

In my outlier opinion, support for continuations would make the Scala language more accessible to people coming from Lisp and Scheme.

#2

The continuations plugin was indeed discontinued because nobody was volunteering to maintain it. If people feel differently now, and have time to spend, it would be nice to restart the effort. But it will be a lot of work.

1 Like
#3

It would be a shame to lose such an interesting and flexible feature. I was looking forward to using it.

#4

I made a video about CPS a while ago with the plugin for Scala 2.12. It should be enough to at least get you started playing with them https://youtu.be/93NZXOGG8ak

#5

@agilesteel, so is it your understand that this still works in 2.12.8 as you describe in the video?

#6

Would it be worth it to work on this since it seems like it will be supported on the JVM level in project loom? https://openjdk.java.net/projects/loom/

1 Like
#7

Does this mean the jvm is finally going to support tail call optimization or is it just another feasibility study?

#8

AFAIU, I think it will be possible to do tail call optimization in terms of the bytecode

As adding the ability to manipulate call stacks to the JVM will undoubtedly be required, it is also the goal of this project to add an even lighter-weight construct that will allow unwinding the stack to some point and then invoke a method with given arguments (basically, a generalization of efficient tail-calls). We will call that feature unwind-and-invoke , or UAI. It is not the goal of this project to add an automatic tail-call optimization to the JVM.

https://cr.openjdk.java.net/~rpressler/loom/Loom-Proposal.html

but I think the scala compiler will still need to support this. It could implement tail call optimization (TCO) in terms of unwind-and-invoke (UAI). But yeah I’m no expert on the subject, that was just my impression.

#9

The RFP is still open. If it isn’t implemented in any of the vms in in 13, it will remain open until the vm team is confident that it can not be done.

#10

A new volunteer maintainer for the scala-continuations plugin has appeared at https://github.com/scala/scala-continuations/issues/49 , perhaps this will result in some continued development, especially if other volunteers become involved as well

no 2.13 upgrade has been attempted yet afaik, that’s https://github.com/scala/scala-continuations/issues/37

3 Likes