Monday, March 31, 2003

Continuations and VMs

Dan Sugalski:

Anyway, a continuation is essentially a closure that, in addition to closing over the lexical environment, also closes over the control chain. (Well, OK, control stack, but if you’re doing continuations odds are it’s a singly linked list rather than a real stack.) CS texts generally go on about continuations being “the rest of the program” or “gotos with arguments” or suchlike stuff. If those float your boat, great—they never made sense to me.

Yeah, I think it depends on whether you are looking at this from the angle of implementation or theory. If you’re writing a VM, then you think in terms of closing over the control chain. If you’re doing denotational semantics, you think in terms of lambdas for the rest of the program.

Update: Here’s part 2.

2 Comments RSS · Twitter


I went with the more implementation-oriented description partly because that's how I think about it and partly because I figured that if a half-dozen theory-oriented explanations didn't help someone then another wouldn't help.

Given the number of people that I know that really understand Lisp and/or Scheme is very small (and I'm quite close to MIT, one of the big hotbeds of Lisp) it's not surprising that a lambda-based explanation doesn't help much. (Nor that continuations are, in their own way, a Deeply Evil thing, but that's part of their charm)


Interesting blog, keep up the good work =)

Leave a Comment