It's actually a big tradeoff Espruino makes rather than a JS problem. If it used bytecode it'd be relatively easy to break execution, but Espruino's parse+run behaviour means you have to have a separate stack for it.
It sucks, because in ES6 they're introducing yield in JS itself - which is going to be dead tricky to implement.
could there be places where an 'safe' interrupt in such a block could happen which would allow marking the conext in the stack and crating a new context for a 'pseudo multi-threading'?
Well, that's the thing. 'dead tricky' - not impossible. The interpreter could 'back out', writing 'I was in that for loop, that try block, and that function', and then try and recurse back to that exact position later on. It'd just be pretty inefficient.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
It's actually a big tradeoff Espruino makes rather than a JS problem. If it used bytecode it'd be relatively easy to break execution, but Espruino's parse+run behaviour means you have to have a separate stack for it.
It sucks, because in ES6 they're introducing
yield
in JS itself - which is going to be dead tricky to implement.Well, that's the thing. 'dead tricky' - not impossible. The interpreter could 'back out', writing 'I was in that for loop, that try block, and that function', and then try and recurse back to that exact position later on. It'd just be pretty inefficient.