W3C home > Mailing lists > Public > public-webplatform@w3.org > October 2012

Re: JavaScript/ECMAScript Styling and Citation

From: Andrew Rowls <eternicode@gmail.com>
Date: Wed, 17 Oct 2012 08:28:24 -0400
Message-ID: <507EA468.2010501@gmail.com>
To: Tobie Langel <tobie@fb.com>
CC: "Pete L." <plamoni@gmail.com>, "WebPlatform.org" <public-webplatform@w3.org>
> TBH, It's unenforceable unless there's proper tooling. I'd leave it
> open and have a page discussing the various styles pros and cons.

Though technically unenforceable (for now?), I think it would still be beneficial to have official guidelines to point people to.  A discussion on pros and cons is well and good, but flavor-of-the-week style in examples would just be confusing.  Better to have a little official consistency and something to back it up than to have no consistency.

> i) a + 1; //returns 5

This is simply wrong; "return" has a specific meaning in JS (returning a value from a function).  Better not to confuse that with anything else.

> ii) a + 1; // 5

I like this style.  However, the python dev in me is saying "Explicit is better than implicit", and there's an implicit verb here. "//is 5" is the closest thing that's not implicit, so I'll throw my vote in there.

> iii) console.log(a + 1); //prints 5
> iv) document.write(a + 1); //prints 5
> v) a + 1 = 5

These should not be things.

> vi) a + 1; //=> 5

Looks too much like a valid syntax for my taste.  Better to use English in the comments, I think.

> I strongly favor vi, here.

When did this become about editors? :P

Andrew
Received on Wednesday, 17 October 2012 12:28:58 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:57:34 UTC