4 ms·
Well to be fair Javascript is kind of limited so Ryan does not have language support for coroutines unless he wants to redesign Javascript. Even better for node
by shirro 15y ago
Well to be fair Javascript is kind of limited so Ryan does not have language support for coroutines unless he wants to redesign Javascript. Even better for node.js would be something a bit more CSP-like such as goroutines and channels but again - Javascript. If you want Javascript with coroutines you can always use Lua.
- someone13 15y agoAnd heck, there's even a Node.js-ish library for Lua: https://github.com/luvit/luvit https://github.com/luvit/luvit
- politician 15y agoTangent: Does anyone know if Node.js on NaCl is possible? exists?
- wmf 15y agoI must be missing something; if you're in the browser you already have JavaScript.
- LeafStorm 15y agoSpeaking of Lua, it doesn't actually have any language constructs for coroutines - coroutine creation and switching is handled entirely via library functions in the `coroutine` package. So while adding coroutine support to V8 would probably require some substantial internal rewrites, it wouldn't necessitate changing the language - just add a global Coroutine object with the coroutine-switching functions like create, resume, yield...
- silentbicycle 15y agoRight, it just needs a sufficiently powerful C API and internals designed with coroutines in mind. ("just" sounds out of place, there...) If you want to look at the Lua coroutine implementation, start at auxresume (http://www.lua.org/source/5.1/lbaselib.c.html#auxresume http://www.lua.org/source/5.1/lbaselib.c.html#auxresume) in lbaselib.c, and the functions tagged luaB_ more generally. (In 5.2, they've been moved to their own file, lcorolib.c.)