How to implement continuations?

后端 未结 12 1590
清酒与你
清酒与你 2020-12-22 16:33

I\'m working on a Scheme interpreter written in C. Currently it uses the C runtime stack as its own stack, which is presenting a minor problem with implementing continuation

12条回答
  •  长情又很酷
    2020-12-22 17:05

    Patrick is correct, the only way you can really do this is to use an explicit stack in your interpreter, and hoist the appropriate segment of stack into the heap when you need to convert to a continuation.

    This is basically the same as what is needed to support closures in languages that support them (closures and continuations being somewhat related).

提交回复
热议问题