by Normal_gaussian · 10y ago · 0 comments
Both vivid and accurate.
In order to combat trailing commas I normally place the comma on the following line, e.g.
{ "time": "3 minutes past four"
, "age": 229
, "sex": "monoecious species"
, "appearance": "Tree-like. It's a tree."
}
uint8_t *data // Yada
, *buffer // Ya
;
var javascript
, variable = 6
, declarations = [ "This is taking too long", "Yep" ]
, mix = [ "Flour", "Sugar", "Water" ]
, types = { 'old' : (d) => { return d < new Date }
, 'new' : (d) => { return d > new Date }
, 'borrowed': (o) => { return false }
, 'blue' : (c) => { return true }
}
, regularly = new Date().toISOString()
;
With such a format there is only ever a problem deleting the first line, which I find is much much harder to do without also noticing what you've done to the larger statement.Ah okay, so you're that guy whose code I have to reformat in every new job.
Of course don't commit reformats where it diverges from the codebase.
, "age": 229
, "appearance": "Tree-like. It's a tree."
, "sex": "monoecious species"
{ "time": "3 minutes past four"
}
and the syntax is broken. With trailing commas, the syntax always stays valid: {
"age": 229,
"appearance": "Tree-like. It's a tree.",
"sex": "monoecious species",
"time": "3 minutes past four",
} {
, "age": 229
, "appearance": "Tree-like. It's a tree."
, "sex": "monoecious species"
, "time": "3 minutes past four"
}edit: I was wrong: http://www.lysator.liu.se/c/ANSI-C-grammar-y.html#initialize...
Which to be honest is what matters. However I would imagine that a lot of the problem grokking it is due to not being used to it.
It looks easier for me; I'm far more likely to notice a missing comma.
But I'm sure you must have a valid point, if you would elucidate?