4 ms·
Hi ggchappell. First of all, thanks for your feedback. You're quite right about (2); but there's a new Javascript version coming out soon that proposes generato
by dionyziz 15y ago
Hi ggchappell. First of all, thanks for your feedback. You're quite right about (2); but there's a new Javascript version coming out soon that proposes generators and 'yield' similar to how Python uses them. When it comes out and is supported by most browsers, we can probably implement that (or just use native syntax and get rid of stream.js altogether).
As for (1), I'd be happy to hear a proposal. If you'd like to work on this, feel free to submit an issue or even a pull request on github — suggestions like this are very welcome. Thanks! :)
- buddydvd 15y agoHere's a project that simulates the "yield" keyword with current version of JavaScript: https://bitbucket.org/balpha/lyfe/wiki/Home https://bitbucket.org/balpha/lyfe/wiki/Home
- ajuc 15y agoThanks for this link, I've been looking for something like that. Generators like in Python allow for nice AI scripting with explicite time-sharing - each AI actor is generator function, that in main loop has yield statement. That way it all works in one thread, and ai code can be written straightforward, like each actor had it's own thread.
- ggchappell 15y agoWell, I'm certainly no JS expert. I doubt I'm the guy to figure out what to do here, at this point. In any case, are you sure that JS generators should be considered a "future" thing? I just did a bit of research, and it sounds like you are talking about this proposal: http://wiki.ecmascript.org/doku.php?id=proposals:iterators_and_generators http://wiki.ecmascript.org/doku.php?id=proposals:iterators_a... According to the following page, much/all of that proposal was included in JS 1.7, which was implemented in Firefox 2.0. https://developer.mozilla.org/en/New_in_javascript_1.7 https://developer.mozilla.org/en/New_in_javascript_1.7 And FF 2.0 was released in October 2006. A quick check shows that my FF installation (3.6.22) supports generator functions, and the "yield" keyword, just fine, as long as I say <script type="text/javascript;version=1.7"> Regardless, I'm a little out of my depth here.