[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CPS != call/cc
On Wednesday, August 6, 2003, at 11:00 AM, Peter J. Wasilko, Esq.
>> Well... it can sort of help, but there are some limits. Multiple
>> stacks tend to solve other problems, and they're certainly useful,
>> but for a CPS scheme you really need more of a linked frame system
>> than a stack system, since the control information really builds up a
>> tree (albeit one often with a single branch) rather than a stack.
> I see, so what would an optimal hardware architecture be for
> supporting CPS?
CPS, or continuation-passing-style, is not the same thing as a language
that includes primitives for continuations.
this program is in CPS (w.r.t. user-defined procedures):
(define (fact-cps n k)
(if (= n 0)
(fact-cps (- n 1) (lambda (x) (* x n)))))
Look! No call/cc, no stack-copying. Just procedures that happen to
CPS is called a 'style' because it's just that... a style of
programming. A program is in continuation-passing style if all of its
calls are tail calls.