Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

What is the difference between call/cc and delimited continuations?


The fully-general continuations that call/cc creates require copying chunks of the stack to the heap for storage and back again when they're used. (Or pointing the stack pointer at the heap, which I find even more cringe-inducing.) They're memory hogs whose lifetimes are hard to reason about and they provide relatively little benefit to most programs, which is why Common Lisp doesn't provide them.


My main interest: delimited continuations are only valid within a specific stack extent so they're much for viable for extensive use - one could argue that async/await is kinda the simplest (and most limited) possible delimited continuation implementation.

For a better understanding, https://en.wikipedia.org/wiki/Delimited_continuation didn't feel like a terrible start and I'm far from an expert here.


Oooh: in addition to my other comment. Don't trust me, trust Matthew Flatt when he talks at Microsoft Research: https://youtu.be/IKddmXjYa5U

It contains a very telling comparison about delimited vs undelimited continuations and sows quite clearly by you always want delimited ones.


They are faster, easier to reason about, less prone to leak memory and are always what you want. Everyone except maybe the chicken scheme people agree, but call/cc is free for them due to their GC strategy.


Chicken and Cyclone share the same gc strategy.


Delimited continuations, a.k.a composable continuations, are. a generalization of control operators such as call/cc.

https://en.wikipedia.org/wiki/Delimited_continuation




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: