Hacker News new | ask | show | jobs
by gpderetta 861 days ago
Continuations are just closures in cps. Closures are just functions plus an environment parameter. Functions are just gotos plus a link pointer. Yet each abstraction is more than the sum of its components.
1 comments

Continuations are closures because they capture everything that a closure would capture at the same point in the execution. But they also capture more.

In CPS, continuations are often closures. But: those closures also close over the surrounding function's hidden continuation parameter k, and make essential use of it! The last continuation-lambda in the function has to call k to simulate the return.