SE-0257: Eliding commas from multiline expression lists

I've moved from reluctantly +1 to reluctantly -1, because of the implications of the following:

  • I have not seen or managed to come up with a single example where a semicolon is necessary at the end of a line. (good)

  • I have seen and can come up with lots of examples where a comma will be necessary at the end of a line. (not so good)

Or put differently:

  • A semicolon at the end of a line is never needed.

  • A comma at the end of a line will sometimes be needed.


The above makes comma elision (as proposed) much more complex and confusing than semicolon elision (as can be seen from much of the discussion here).

However, note that comma elision would be exactly as straight forward as semicolon elision if we restricted it so that it was "only" allowed for:

  • dictionary literals
  • fully-labeled argument lists
  • parameter lists (unlabeled params still have eg _ arg: so they're ok)
  • fully-labeled tuples

That is, comma elision would only be allowed in contexts where commas are truly redundant (the labels/keys and colon makes them so), and (afaics) this way all commas could be elided without ambiguities, not only the ones at the end of a line.

Since the label/key and colon is effectively, well not strictly a separator, but rather a "bullet point" or introduction to each item, perhaps array literals and other un- or partially labeled constructs could be allowed provided they too used an item-introducing colon even for the unlabeled items:

let a: [SomeEnum] = [
  _: .foo
         .bar
  _: .bar
  _: .foo.bar.foo
         .bar.foo.bar
  _: foo _: foo.bar _: foo
]

print(
    _: "Hello"
    _: "world"
    separator: ", " // ;-)
    terminator: "!\n"
)

func dividingClosed(
    _ other: Polycurve
    straightIntersections: Bool = false
    threshold: Float = 1/64
) -> (
    inside: [Polycurve]
    outside: [Polycurve]
    intersections: [Float]
)
{
    ...
}

let package = Package(
    name: "Paper"
    products: [
        _: .executable(name: "tool" targets: ["tool"])
        _: .library(name: "Paper" targets: ["Paper"])
    ...

(No, the _: is not pretty, I agree, it's just a first attempt to come up with something that makes my envisioned more consistent comma elision work also for unlabeled constructs.)