4 ms·
Would your language also accept this? list = %[ chair, table ] And this? list = %[ chair, table, ]
by teo_zero 3y ago
Would your language also accept this?
list = %[
chair, table
]
And this?
list = %[
chair, table,
]
- hnlmorg 3y agoYes it would: » %[ chair, table ] [ "chair", "table" ] » %[ chair, table, ] [ "chair", "table" ] Here you can see that internally it understands you're writing a JSON object however it relaxes the semantics a little (without going full on YAML) because chasing that erroneous comma is probably the least fun part of programming.
- teo_zero 3y agoSo, accepting the spurious comma at the end of the list and not requiring commas when there's a newline can coexist. I would say they are tho orthogonal properties. You can support the latter without opposing the former.
- D-Coder 3y agoClearly, whether the language considers commas necessary or optional should be in a config file.
- hnlmorg 3y agoSure, but that’s not what the linked article discusses. It specifically states that commas are mandatory on each line. Not that the rule for commas is relaxed. And what I’m arguing is that requiring commas on each line is pushing the syntax in the wrong direction.