3 ms·
You are assuming that trailing commas are ignored as valid, which is true of JavaScript but not of JSON or of C (the other example).
by saurik 10y ago
You are assuming that trailing commas are ignored as valid, which is true of JavaScript but not of JSON or of C (the other example).
- majewsky 10y agoYes, I'm aware of this being an error in JSON (which is precisely the point of the discussion). I wasn't aware that it's a problem in C. Maybe gcc is more lenient here.
- tptacek 10y agoTrailing commas are allowed in C!
- mzs 10y agoC89 v. C99 difference IIRC edit: I was wrong: http://www.lysator.liu.se/c/ANSI-C-grammar-y.html#initializer http://www.lysator.liu.se/c/ANSI-C-grammar-y.html#initialize...
- saurik 10y agoNo: tptacek did not bother paying attention to the context; as far as I know "uint8_t * data, * buffer, ;" (spaces added after * to avoid italics) would never be valid.
- tptacek 10y agoHow is that the context? In the sense of the intersection between Javascript and JSON, trailing commas have pretty much always worked in C, which is something all of us who write code that generates C rely on, like a lot.
- mzs 10y agoI googled and trailing comma was allowed since C89, I was wrong. For code that generates code I always did something like this cause of that mistake: { a, b , c ... , z };
- saurik 10y agoThe contextual example from C was "uint8_t * data, * buffer;" (spaces added to avoid italics), and no: a trailing comma is absolutely not allowed.
- tptacek 10y agoReplied here, to the first time I saw you write this: https://news.ycombinator.com/item?id=12368022 https://news.ycombinator.com/item?id=12368022