13 ms·
Errors/exceptions, for one, are implemented using continuations.
by dauphin 16y ago
Errors/exceptions, for one, are implemented using continuations.
- axod 16y agoSounds terribly inefficient to me, but what do I know -shrug-
- dauphin 16y agoYou know, if it weren't really impratical, numbers in Arc would be represented by Church numerals, "hash tables" would be alists, strings would be lists, etc. That's a credo :-)
- jrockway 16y agoAll control flow is a subset of continuations. The stack is a continuation (calling a function is call-with-current-continuation, return is just calling the "current continuation"), loops are continuations (with the non-local control flow, like break/last/redo/etc.), exceptions are continuations (like functions, but returning to the frame with the error handler), etc. Continuations are the general solution to things that are normally treated as different. So continuations are just as efficient (or inefficient) as calling functions or throwing exceptions. In a web app context, though, it's kind of silly to keep a stack around to handler something like clicking a link that returns the contents of database row foo. People do this, call it continuations, and then run into problems. The problem is not continuations, the problem is that you are treating HTTP as a session, not as a series of request/responses. (The opposite of this style is REST.)
- ezalor 16y agoEat this: "The continuation that obeys only obvious stack semantics, O grasshopper, is not the true continuation." -- Guy Steele
- sedachv 16y agoIn theory yes, in practice you need to reify the stack (even for one-shot continuations). Clinger, Hartheimer and Ost have a really good survey paper of the different ways to do that: http://www.scribd.com/doc/47221367/Clinger-Implementation-Strategies-for-First-class-Continuations http://www.scribd.com/doc/47221367/Clinger-Implementation-St...