lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Wed, Aug 1, 2018 at 3:02 PM, Sean Conner <sean@conman.org> wrote:
> It was thus said that the Great Coda Highland once stated:
>>
>> Well, given that coroutines CAN be implemented in terms of other
>> language features, you could implement them at a higher level -- some
>> sort of automated source transformation at parse time so that the
>> VM/JIT/whatever doesn't have to worry about it. The Javascript
>> community has done this for quite a while now in order to work around
>> lack of browser-side support, and while the generated code is really
>> hard to read it's definitely just mechanical.
>
>   You would still need to inform the compiler what the blocking points are
> and ... no.  Just no.
>
>   -spc (You can pry coroutines from my cold dead hands ... )
>

You misunderstand: The recommendation is to PRESERVE the coroutine
syntax and do a preprocessing pass to translate that into something
more amenable to efficient VM implementation. As mentioned, this is
what the Javascript community has been doing for a couple years. The
yield statement gets transformed behind the scenes into returning some
sort of state object that can be used to resume execution.

Under no circumstances would I want to remove coroutines from the
actual language syntax, because they are far too useful.

/s/ Adam