bennorth / pytch

Other
3 stars 1 forks source link

Yield in more places #9

Open g-d-strong opened 5 years ago

g-d-strong commented 5 years ago

Pytch programs yield their thread at the end of While and For loop bodies. we should also yield in a few other places:

g-d-strong commented 5 years ago

ast.js:astForSuite is the function that builds an AST for a block body; if we yield at the end of every body then we're definitely yielding enough (maybe too much?)

g-d-strong commented 5 years ago

via: https://scratch.mit.edu/discuss/topic/183102/?page=1#post-1787810

"Here are the rules that determine whether or not Scratch will switch to executing another thread/stack of blocks: At the beginning or end of a loop, like a ‘forever’ or a ‘repeat (n)’, Scratch will switch threads. In custom block set to ‘run without screen refresh’, Scratch will not switch threads, even if it encounters a looping block, unless the custom block has been running for more than half of a second. Certain other blocks cause Scratch to switch threads. These are 'stop [all]', ‘wait until <>’ when the condition is false, 'broadcast [] and wait', 'switch backdrop to [] and wait', ‘next backdrop’, 'stop [this script]' when inside a custom block definition, and custom blocks when set to ‘run w/o screen refresh’ and called recursively(inside their own definition). Some extension blocks cause Scratch to switch threads."