[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Why can't a coroutine yield inside an iterator?
- From: Matt Campbell <mattc@...>
- Date: Thu, 09 Mar 2006 13:31:10 -0600
I noticed that unless Lua is patched with something like Coco that uses
machine-dependent tricks, a Lua coroutine can't yield inside an
iterator. Why is this? I understand why a coroutine can't yield if
there's a C function somewhere in the call stack; that would require
switching C stacks. However, it seems that it would be possible for the
VM to save its state inside an iterator so a coroutine can yield. Would
this require a lot of work or add significant overhead per coroutine? I
think the ability to yield inside an iterator would be quite useful
sometimes, particularly in some producer/consumer scenarios. Thanks.
"The Accessibility Anywhere People"