Nannying (was: Array comprehension syntax)

David Herman dherman at mozilla.com
Mon Sep 24 22:19:26 PDT 2012


On Sep 24, 2012, at 12:37 PM, Jason Orendorff <jason.orendorff at gmail.com> wrote:

> I want to defend my kind of nannying.  :-)
> 
> I favor rejecting `if x = y` in comprehensions because it's almost
> always going to be a bug, and a tough bug to diagnose.

I don't. Where do you draw the line? if (x = y) as well? if ((x = y))? This is enforcing idioms that JS does not enforce elsewhere. Leave this to the linters.

> Here's another program I think we should reject, for the same reason:
> 
>    var titles = books.map(b => {title: b.title});

Again, I disagree and think this should be left to linters. I don't want to start partially enforcing coding/parenthesis styles in a limited set of contexts in the language.

> Beyond likely mistakes, my sympathy for nannying drops off quickly.
> In particular, there's little to gain from trying to enforce
> readability in JS at the language level.  It's just not that kind of
> language.

Here we agree. :)

Dave



More information about the es-discuss mailing list