call/cc in Lua - Possible?

前端 未结 6 493
小鲜肉
小鲜肉 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:34

    I guess you forgot the part about writing your program in continuation passing style. Once you do that, call/cc is trivial (in Lua or in any other language), as the continuation will be an explicit parameter to all functions (call/cc included).

    PS: besides closures, you also need proper tail calls to program in continuation passing style.

提交回复
热议问题