Comment by _old_dude_
9 hours ago
You need more than that for the example with setTimeout(). It requires to be able to freeze the stack and then go back later.
You need stackful coroutine (like goroutine) for that.
9 hours ago
You need more than that for the example with setTimeout(). It requires to be able to freeze the stack and then go back later.
You need stackful coroutine (like goroutine) for that.
That's very interesting, thanks! It gave me a brainwave and I wondered I could implement that in Bluefin. I'm pretty sure Bluefin's Request[1] is a second class stackful coroutine, and sure enough it turns out to be possible, so I'm pleased about that.
Or in Lua you'd wrap the initial call in a coroutine, possibly with coronest[a] or something similar to make handling the effects at the right layer easier.
And so then the outer code is a loop around coroutine.resume, and the inner code uses coroutine.yield to perform an effect.
[a]: https://github.com/saucisson/lua-coronest