On 10/13/13 6:33 PM, [email protected] wrote:
> Don't know, I only know behavior of Python yield statement, but
> Javascript one was developed following it and I'm 90% secure it follows
> the same behaviour (almost all new functionalities of Javascript are
> being borrowed from Python since seems Mozilla Javascript implementors
> are Python ex-programmers in purpose) so yes, I believe it should work
> this way :-)
It's slightly more complex than [my undersatnding of] your original
phrasing, but in a word, yes, it behaves essentially as in Python.
e.g., using Task.js [1], with a proper (and trivial) definition of
wait(), the following implements a polling loop that does not block the
event loop:
Tasks.spawn(function* () {
while (true) {
yield wait();
poll();
}
});
[1] http://taskjs.org/
--
David Rajchenbach-Teller, PhD
Performance Team, Mozilla