call/cc in Lua - Possible?

前端 未结 6 524
小鲜肉
小鲜肉 2020-12-13 19:46

The Wikipedia article on Continuation says:
\"In any language which supports closures, it is possible to write programs in continuation passing style an

6条回答
  •  南笙
    南笙 (楼主)
    2020-12-13 20:40

    Answering the question about plans for call/cc in Lua: There are no plans for call/cc in Lua. Capturing a continuation is either too expensive or require some code analsis well beyond what the Lua compiler can do. There is also the problem that Lua continuations may include parts in C.

    With coroutines, however, we can already implement call/cc1 in Lua (one-shot continuations). That is good enough for many uses of continuations.

提交回复
热议问题