3 ms·
Definitely agree with need for iteration syntax and yieldfrom keyword. The iteration syntax will probably have be something different than "for a in b" because
by almost 13y ago
Definitely agree with need for iteration syntax and yieldfrom keyword. The iteration syntax will probably have be something different than "for a in b" because that's already used for array-like iteration and adding another case would slow existing code down (all of which wouldn't be using it of course). For yieldfrom the code it needs to generate is something like this:
var generator = g1(), result = {}, send;
while(!result.done) {
result = generator.send(send);
send = yield result.value;
}
- bayesianhorse 13y agoI would suggest "for a from b". If that only uses .next and .send, it might work with class instances too, like the iterator protocol in Python.
- apaprocki 13y ago"for of" is actively being added to V8. It should not be very long before it lands in V8 (and thus in Node). I don't like the idea of another keyword that at best acts exactly the same (or at worst acts subtly different).
- almost 13y agoCoffeeScript already has an of operator (like js in) and an in operator (array like iteration) neither of which could easily be made to both (I think). So we'd probably need a new name. Once "of" is in V8 we can compile to it directly though.
- wycats 13y agoIt's not clear to me how to compile directly to it without breaking CoffeeScript code that already uses for/of. Is the idea to break compatibility with existing CoffeeScript code? See my longer question about this upthread.
- almost 13y agoI honestly don't know, this was just a quick hack this morning while I had a hangover :) I think it's good to have the conversation though!
- bayesianhorse 13y agoI'm not current on what kind of compatibility coffeescript is trying to keep, but IE6 certainly not going to like the newer V8 features...