

CoffeeScript comprehensions are broken - mattdw
http://brehaut.net/blog/2011/coffeescript_comprehensions

======
TrevorBurnham
Despite its linkbait title, this is one of the more thoughtful pieces on
CoffeeScript that I've seen in a while. The behavior of nested list
comprehensions in CoffeeScript has been the subject of much debate, and the
excellent Coco fork adopts the Python-esque behavior.

However, I think the objections here would be moot if CoffeeScript's "list
comprehensions" were called something else. They don't behave like list
comprehensions in Python, but their behavior is perfectly consistent with the
CoffeeScript philosophy that every expression has a value, and loops are
expressions. That means that a single loop has a single list as its value, and
a loop within a loop produces a list of lists. Note that unlike Python—or
Harmony—there's no special delimiter to say "Give me a list comprehension."
It's just the natural implication of how expressions in CoffeeScript work.

------
mattdw
(This appears to be by design: <https://github.com/jashkenas/coffee-
script/issues/1191>)

~~~
telemachos
Note that jashkenas reopened that issue[1] (which was closed in April) in
response to this article.

You have to love a BDFL who's willing to discuss things.

[1] [https://github.com/jashkenas/coffee-
script/issues/1191#issue...](https://github.com/jashkenas/coffee-
script/issues/1191#issuecomment-2081256)

