lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Tony Finch <dot@dotat.at> writes:

> Charles Engelhard <ochuckles@gmail.com> wrote:
>
>> - It's a missed opportunity to have the power of Scheme-style continuations
>> with an understandable interface.
>
> I think this is a contradiction in terms. Continuations need to be tamed
> in some way to be understandable. For instance, Lua's coroutines are
> essentially one-shot continuations.
>
> Fully general first class continuations are difficult to implement
> efficiently. They either put enormous stress on the garbage collector
> or they require some kind of stack copying.

It is not that bad.  You put the return stack on the heap, and leave
cleaning it up to the garbage collector.  Since garbage collection is a
major part of most dynamic languages (including Lua) anyway, the impact
is tolerable.

The Scheme compiler Chicken actually uses the normal call instructions
IIRC.  It just does not return, and the stack gets garbage collected
occasionally.

> Lua also needs to work in a standard C environment which means there
> would have to be some awkward restrictions on continuations.

IIRC, Chicken mixes with C.

-- 
David Kastrup