SE-0439: Allow trailing comma in comma-separated lists

A solid +1 here.

If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?

I recognize my younger self in the “it looks wrong and makes things complicated“ flavor of some of the comments against. I used to feel exactly the same way.

Then, after using the corresponding feature extensively in Ruby and Javascript, I suddenly found it hard to live without — and immensely irritating when absent. The freedom to reorder lists by line is lovely, and quickly stops looking wrong.

(As always in these forums, it seems familiarity reigns supreme.)

Does this proposal fit well with the feel and direction of Swift?

There are some concerns about the disallowed cases. That's fair; where clauses for protocol members in particular are something one might want to put on multiple lines, and folks will no doubt find it frustrating when the trailing comma is disallowed in that position.

However, the inconsistency these corner cases present is far smaller than the current inconsistency between array/dict literals and function call arguments:

// So in today's Swift, I can do this…
print([
  "foo",
  "bar",
])

// …but not this?!
print(
  "foo",
  "bar",
)

Swift's syntax has always favored “it mostly works for language users” over “it makes sense for parser authors.” This proposal is consistent with that precedent.

How much effort did you put into your review?

A quick read of the full proposal, and a skim of existing comments.

29 Likes