Hasty Briefsbeta

Bilingual

Nontrailing separators do not spark joy

2 days ago
  • JSON's lack of trailing commas complicates adding or removing key-value pairs, requiring different transformations than if trailing commas were allowed.
  • Haskell's record syntax uses leading commas, making it easier to modify the last row but harder to change the first.
  • TLA+ disallows trailing commas, causing frequent issues when adding variables, while its PlusCal extension does not have this problem.
  • Prolog uses a period to terminate rules, not a trailing separator, which can lead to parsing ambiguity if commas were used instead.
  • Languages like Go and Python allow trailing commas in data structures but not leading commas, while Alloy permits both leading and trailing commas.
  • Arguments against trailing separators include parsing ambiguity, as seen in Prolog rule boundaries and Ruby method chaining.
  • Python uses a trailing comma to distinguish a single-element tuple from a parenthesized expression, showing an edge case benefit.