- From: David Rajchenbach-Teller <dteller@mozilla.com>
- Date: Sun, 13 Oct 2013 20:45:37 +0200
- To: "piranna@gmail.com" <piranna@gmail.com>
- CC: James Greene <james.m.greene@gmail.com>, David Bruant <bruant.d@gmail.com>, Jonas Sicking <jonas@sicking.cc>, public-webapps <public-webapps@w3.org>, Glenn Maynard <glenn@zewt.org>, Andrea Marchesini <amarchesini@mozilla.com>
On 10/13/13 6:33 PM, piranna@gmail.com 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
Received on Sunday, 13 October 2013 18:46:06 UTC