u/FunctionalFox1312in r/Clojure • Recommends
On “Continuations in Clojure”
Here's a good talk on continuations in Scheme.
Here are some slides that explain Continuation Passing Style using both Lisp & JavaScript.
Continuations are a control flow primitive. Have you ever used goto in something like C where you can just jump to a random line? You can think of continuations as a super powered, first class goto- you can pass around them around like normal variables, and invoke them at any time to jump to their point of creation. So far, you're right, couldn't we just do this with function calls? But continuations also *save the state of the program* when they are created, a snapshot of the callstack. That is something you can't exactly capture with function appli…