4 ms·
While comprehension is, generators are not part of Coffee-script.
by yuchi 14y ago
While comprehension is, generators are not part of Coffee-script.
- doublerebel 14y agoI should have been more specific. The generator expressions specified in Harmony [1] are the exact same syntax as in CoffeeScript. [1] http://wiki.ecmascript.org/doku.php?id=harmony:generator_expressions http://wiki.ecmascript.org/doku.php?id=harmony:generator_exp...
- masklinn 14y agoThat would be because both are lifted from Python. And it is not the exact same syntax (Harmony uses `for (e0 of e1)` paralleling its for-of iteration syntax and semantics), and more importantly the semantics are completely different. Finally, the syntactic similarity would already be covered by the array comprehension mention. Thus, there's nothing even remotely close to generator expressions in coffeescript at this point, as far as I know.
- doublerebel 14y agoWell, I suppose downvotes are what I get for commenting at 6 in the morning at 35,000 ft. Correct, as the article mentions Harmony takes many cues from Python, as does Coffee, and Coffee cannot magically create features that aren't supported by the underlying JS. However, it is possible to get a near-equivalent of generators (albeit with more overhead) using Continuation Passing Style and Iced CoffeeScript await/defer or another CPS lib. There are many who have explored this concept before myself, and I am now inspired to create an example to demonstrate IcedCS's ability with such a concept once I'm through the holiday.
- yuchi 14y agoActually, using ICS and CPS to build generators forces a reversed approach. With generators is the called function to own the process, in await/defer is the calling context which knows about the "generator like" functionality. And you're completely right about Coffee not able to implement ES6 generators.