News for hackers. Stuff that matters.
Re:Lua VM running in a WASM environment by vvanders on Saturday March 18, 2017 @12:36PM (#13902056)
Huh, didn't know about generators, learn something new every day(although like everything with JS support looks a bit spotty).
Re:Lua VM running in a WASM environment by pygy_ on Saturday March 18, 2017 @12:48PM (#13902119)
Generators are also less general. You can't `yield` from a non-generator function. In Lua, coroutines are implemented as a library, not as a core language/syntax thing.
Re:Lua VM running in a WASM environment by vvanders on Saturday March 18, 2017 @01:09PM (#13902264)
Pretty sure coroutines are a core part of the language since there's specific C APIs around them but I could be wrong.
Re:Lua VM running in a WASM environment by pygy_ on Sunday March 19, 2017 @12:04PM (#13907875)
The library requires low level access to the VM, but you can yield from anywhere, and pass `coroutine.yield` as a value to higher order functions.

However, there are (were?) restrictions when C functions are present on the call stack between `coroutine.resume` and coroutine.yield`.

Edit: not that low level, actually, here's the coroutine implementation, built on top of the public Lua C API:

http://www.lua.org/source/5.3/lcorolib.c.html

(167 lines including white space and comments).