Concatenative language/Continuations

Continuations are a feature originally found in Scheme. They have a reputation for being hard to understand, and somewhat mysterious. In Concatenative languages, continuations have a very simple explanation: they are a snapshot of the stacks. In Factor, a continuation is an instance of a tuple with several slots, one for each stack:

TUPLE: continuation data call retain name catch ;

Reifying a continuation creates a copy of the stacks, and reflecting it restores the saved copies. That's the only primitive needed to implement exception handling, coroutines, co-operative threads, and backtracking in Factor.

This revision created on Sat, 3 Jan 2009 01:15:02 by slava