> Peter Bex scripsit:
>
>> What is used instead of CPS nowadays?
>
> The typical view is that it's more important to optimize normal calls
> and returns than calls to escape procedures, so a stack is used and then
> copied when call/cc is invoked. Chicken allocates stack frames on a
> first-generation heap, which means that you are paying to GC that heap,
> as well as the (nowadays small) space cost of retaining the C return
> addresses on the stack that are never used.
That's right. But the really important point is TCO which is
crucial. Without generating one big function, and/or using trampolines
it is not possibly to portably generate C without losing full tail
calls. One bug function is in practice not possible. Trampolines pay
for cross-module calls and are expensive by requiring to maintain a
"shadow" stack (this may be improved by generating big C functions but
that doesn't scale too well in terms of gcc compile
times). Cheney-on-the-MTA handles call/cc, TCO and first-level GC
using a single technique, generates small functions that compile fast
and keeps the C function calling conventions.
>
>> Does it give you "free" call/cc?
>
> In effect, Chicken call/cc is not free; its cost is amortized over
> all calls. However, that cost is paid even by programs that never
> use call/cc.
Also correct. Note that cheap continuations become important when
they are used to implement threading.
cheers,
felix