Simple explanation of *delimited* continuations

Just last month, I was talking about how raise/catch could interact across C callouts, and inadvertently described reset, without realizing it at the time.

I’d been putting off study of delimited continuations. After all, I’d read that call/cc can implement delimited continuations, so what’s the big deal. A lot, apparently. Thanks to anvsdt for giving me the necessary “whack to the side of the head”.

But the best characterization is probably this 2008 comment from Oleg Kiselyov, (from this talk, mentioned)

I’m obsessed in pointing out that every programmer already knows and understands the delimited continuations; they might not know that word though. Everyone knows that when a process executes a system call like read, it gets suspended. When the disk delivers the data, the process is resumed. That suspension of a process is its continuation. It is delimited: it is not the check-point of the whole OS, it is the check-point of a process only, from the invocation of main() up to the point main() returns. Normally these suspensions are resumed only once, but can be zero times (exit) or twice (fork).

Which not only rearranged my brain a little bit, but also might work better explaining continuations to colleagues.

Leave a comment

Your email address will not be published. Required fields are marked *