5 ms·
{ home = "/home/bill" , privateKey = "/home/bill/.ssh/id_ed25519" , publicKey = "/home/blil/.ssh/id_ed25519.pub" } This is the most awkward
by svnpenn 4y ago
{ home = "/home/bill"
, privateKey = "/home/bill/.ssh/id_ed25519"
, publicKey = "/home/blil/.ssh/id_ed25519.pub"
}
This is the most awkward abuse of formatting I've seen in a long time. Just allow/require a final trailing comma, and this nonsense goes away
- sshine 4y agoThis is a by-product of Dhall coming from the Haskell community where this formatting was preferred instead of final trailing commas. It has been internalised and was carried on. I say this as someone who looks at this code and thinks "This is totally fine." -- but I admit, I'm environmentally damaged.
- eru 4y agoYes. And, alas, you can't just allow a final trailing comma everywhere in Haskell. Eg ("Foo", 2,) is different from ("Foo", 2) in Haskell thanks to TupleSections. For innocent bystanders: in Haskell ("Foo", 2) is the tuple you'd expect it to be. But ("Foo", 2,) is a function that takes another argument and creates a three-tuple. A Python equivalent would be lambda x: ("Foo", 2, x)
- deleted 4y ago[deleted]
- chriswarbo 4y agoThis style is common in Haskell, Nix and Dhall. It also sees more "mainstream" use, e.g. in SQL.
- layer8 4y agoOr allow a leading comma: { , home = "/home/bill" , privateKey = "/home/bill/.ssh/id_ed25519" , publicKey = "/home/blil/.ssh/id_ed25519.pub" } Or, to make it markdown-ish: { - home = "/home/bill" - privateKey = "/home/bill/.ssh/id_ed25519" - publicKey = "/home/blil/.ssh/id_ed25519.pub" } This is just to play with the idea that leading punctuation may be preferable because it all aligns in the same column.
- lilyball 4y ago> Or allow a leading comma This actually works just fine.
- whateveracct 4y agoTrailing comma is ugly as sin - I love the little "house" my leading commas put my record into :)
- rowanG077 4y agoI feel this is the superior way to format something like that. Trailing commas are nothing but an ugly hack.
- beanjuiceII 4y agoI would actually prefer no comma's {:home "/home/bill" :private-key "/home/bill/.ssh/id_ed25519" :public-key "/home/bill/.ssh/id_ed25519.pub"}
- bigbillheck 4y agoThat's the same as a leading comma.
- doliveira 4y agoYeah, I also really dislike this mixing up of indentation levels because of a language limitation. The "{" denotes a container, and the "," a separation between items of said container, for me it makes sense for them to be nested a level deeper
- eru 4y agoThat's one way to interpret things, but not the only way. In practice, this style reads just fine once you get used to it. Indentation is mostly there as a human convenience, so just has to work well with human brains (and be understood by a computer, if it's significant), but doesn't have to necessarily follow some abstract unified theory of syntax trees.
- ghostwriter 4y agoboth symbols are delimiters, one can choose to align them together even when they are not the same character. Opening and closing braces aren't the same character either, but people have been aligning them for ages, I don't see a reason why commas, while being part of the same expression, should not follow the same principle.
- doliveira 4y agoFor me it's not about being the same character (like you've mentioned, opening and closing braces aren't either), it's about commas and braces indicating different things in the hierarchy. Not to mention the symmetry breaking: an opening brace together with data in a line, then a lonely one at the bottom.
- ghostwriter 4y agoIn a series of declarations, the lonely closing brace at the bottom can be treated as a substitute for an empty line between two entries, as it produces a similar sparse spacing.
- brigandish 4y agoI much prefer this style, I use it wherever I can because I can comment out lines without a trailing comma causing a syntax error. SQL, Ruby… wherever I can. Try it, I doubt you'll go back (unless someone's stupid parser doesn't let you).
- eru 4y agoYou can do the same, if your language allows a final comma. (And that's what the comment you reply to suggests: make Dhall allow a final comma.)
- ghostwriter 4y agoWhat's the point of allowing a trailing comma? A delimiter symbol is a delimiter symbol, be it a an opening curly brace or a comma between elements, and one can simply align delimeters.
- eru 4y agoThe main point is to make git diffs smaller when adding or removing elements, I think.