To play at devil's advocate, please don't. Otherwise you should have written your comment like this:
To me
, consistency is important
. All of my codebase is traditional comma postfix
, so I'll keep using that
; however
, maybe with some new projects I'll try on the comma prefix [...]
... using typography in a typographically sensible way is far more important to readability than an arbitrary "consistency" of punctation. We're humans, not computers, after all.
Why does nobody ever mention the obvious solution? Separate var statements.
They're always correct, they copy without any editing, and the "var"s line up to show that it's a block of assignments the same as commas or whitespace.
With separate var statements, you never end up with this situation:
var foo = 1,
bar = 2
baz = 3
In 90% of the cases the code will run the same whether or not there is a comma on line 2, but in the other 10% you will get burned in odd ways now that `baz` is a global variable.
You can only put var at the beginning of variable declarations, but there are many other places that commas are used as a separator. So that "solution" doesn't apply in general.
Separate vars is what I prefer to do, but JSLint actually recommends that you change multiple var statements to a single var with variables separated by commas (and with a semicolon at the end of course!). (And also all var declarations at the top of the function...).
I use leading commas in any list that is not one liner in C++. This way the code looks pretty, and that is way more important that code that reads like english. :) (I shudder from dread every time I look at applescript...)
And let me play the advocatus Dei
, because that actually looks quite readable
.
Though, more seriously, using English (a natural language) to try to make an
appeal to absurdity about the format style of a formal language, is plain
absurd.