>
> On 29/03/2013 2:35 PM, Tim Hill wrote:
>> You're not going to be able to pull that one off. The fundamental
>> structure of coroutines is different from threads, and nothing you do
>> can really change that (aside from a VERY significant reworking of
>> the Lua code base).
>
> I don't know about that, all he's talking about is conditionally
> injecting yeild() into the code at arbitrary points (such as the end of each
> statement)
>
> This could be done manually with a syntactic substitution. The question is
> whether it can be done using a debug hook or similar mechanism.
That's a correct guess and interpretation. I've done something similar for Java using a byte-code instrumentation during class-loading. Indeed, I was injecting a conditional yield() after each n instructions. Alternatively, it could be done at the beginning of each basic block in the control-flow graph of a function. I know that Groovy language, which is also Java based, does something very similar.