Description
This issue was originally filed by adblockforc...@gmail.com
Support list comprehensions a la Python, or else list somewhere why you won't support them.
Rationale:
- They are voted the number one favorite language feature of Pythonistas, which will help with adoption and evangelism.
- They can be implemented as syntactic sugar and require no new keywords.
- They allow for clearer and shorter looping constructs.
- They allow for a functional style without explicit use of map() and filter().
You will gain converts who love list comprehensions and are tired of them not existing in JavaScript.
I'm sure you know the format, but for everyone else: the list comprehension
[ expr1 for a in list1 if expr2 ]
is roughly equivalent to the JavaScript
(function() {
var result = [];
for (var i = 0; i < list1.length; i++) {
if (expr2)
result.append(expr1); // can refer to a
return result;
)()
and multiple 'for' subclauses are supported.