3 ms·
anyone actually use comma-first syntax? It lets you easily move lines around, too: {"foo": "bar" ,"baz": "hehe" ,"yes": "aligned" ,"better": "this way"
by EGreg 2y ago
anyone actually use comma-first syntax? It lets you easily move lines around, too:
{"foo": "bar"
,"baz": "hehe"
,"yes": "aligned"
,"better": "this way"}
- scottmf 2y agomore easy how?
- AlchemistCamp 2y agoNot the top one!
- nkrisc 2y agoThis has the same number of lines that can’t be moved freely as comma at the end.
- EGreg 2y agoBut visually easier to check Also you can put the last brace on its own line
- nkrisc 2y ago> But visually easier to check I’ll agree with that, since they’re all vertically aligned. > Also you can put the last brace on its own line You can always put the first and last brace on their own line in most languages whether the commas are at the front or end.
- EGreg 2y agoBut in the comma-first case that lets the last line be movable, that was my point basically.
- sham1 2y agoHaskell culture tends to do this kind of stuff for records, FWIW. Of course, in this case, it might even make sense to render this in a way such as the following: { "foo": "bar" , "baz": "hehe" , "yes": "aligned" , "better": "this way" } Because as another person already said, the first line isn't movable, and the last line wasn't either. The first key-value pair does look a tad strange because it doesn't have anything before the key, but nevertheless, now changing things is even easier. Admittedly, it would look nicer if we could have trailing commas, though. Oh well, we have YAML for extra readable record syntax, even with how horrible YAML can get in reality.
- EGreg 2y agoMy opinion: just have commas be optional, like semicolons. Allow linebreaks to insert implied commas