Re:Show HN: Scratch.js – Interactive JavaScript Scratchpad
by angleofrepose on Wednesday November 18, 2020 @01:58PM
(#25140839)
Yes, as the other comments get at the "hack" I'm referring to is a loop transform that adds a timer check to the condition.
[ Parent
| on HN ]
Re:Show HN: Scratch.js – Interactive JavaScript Scratchpad
by jraph on Wednesday November 18, 2020 @02:46PM
(#25141503)
Oh, right, I was not there at all.
Wow, that seems hard to do. One would need to take a lot of things in account, including recursive calls, asynchronous functions / calls and, indeed, even long strings of instructions that are not necessarily part of a loop or recursive calls.
Would a transform that adds the check between every JS instructions where it is possible theoretically solve the problem? is there a solution that does not slow down the code too much and interrupts the code within an acceptable margin?
Re:Show HN: Scratch.js – Interactive JavaScript Scratchpad
by angleofrepose on Wednesday November 18, 2020 @03:23PM
(#25141961)
Yeah! The general case of this is the halting problem...
The best solution I know of is stopify, which the other comments have talked about. I just wonder if there's another take on the situation, something akin to OS task management.