Hasty Briefsbeta

Bilingual

Nontrailing separators do not spark joy

5 hours ago
  • #syntax design
  • #JSON
  • #programming languages
  • Trailing commas in JSON are not allowed, which complicates editing by requiring different text transformations depending on where elements are added or removed.
  • Other languages like Haskell, TLA+, and Prolog also restrict trailing separators, leading to similar editing challenges, with Prolog using periods to terminate rules.
  • Some languages, such as Python and Go, allow trailing commas in data structures, improving editability, but typically do not permit leading separators.
  • Alloy is highly flexible, allowing both leading and trailing commas, and even empty separators, though this can be seen as excessive.
  • Arguments against trailing separators include potential parsing ambiguities, as seen in Prolog and Ruby, where control separators could be misinterpreted.
  • Python uses trailing commas to distinguish single-element tuples from grouped expressions, highlighting a practical use case for trailing data separators.