SE-0257: Eliding commas from multiline expression lists

This is an overstatement of my view of the proposal. My view is that comma separators do not provide value to humans in some important contexts. Specifically, I have looked at a range of EDSL examples which now appear cluttered to me when commas are present. These examples look much better and more clear without commas for all the same reasons Swift code looks much better without semicolons.

Domain specific languages often aim to be syntactically light, allowing the domain itself to be front and center. These languages often consist of lists of declarations (which often include lists of attributes). Nobody in their right mind would design such a language to require commas between each declaration and / or attribute. They are usually designed with one declaration or attribute per line with no line terminator. This proposal supports the embedding of such designs into Swift without the currently required syntactic compromise of trailing commas. These EDSLs can be designed with comma elision in mind, avoiding most or all of the gotchas that may occur when comma elision is used in more general settings.

IMO, supporting the embedding of such languages into Swift in a syntactically light manner is a huge win. Of course YMMV and the benefit any individual Swift programmer realizes will depend upon how often they use declarative EDSLs.

Can you please provide an example of how this proposal breaks existing Swift source code all of which currently uses commas? This proposal does not remove support for commas and does not suggest that people should never use commas except where absolutely necessary. I believe it will require good judgment to decide where comma elision is appropriate and where it is not. I also agree with @John_McCall’s suggestion that a list should either have commas on every line or no lines. IMO, single commas for the purpose of disambiguation would be bad style.

You never responded to @Douglas_Gregor’s disagreement on this point. If you engage this topic in an attempt to get on the same page with him you may end up convincing me to change my mind about comma elision. I don’t have the expertise the two of you have and would appreciate it very much if you were able to agree on the facts.

See the discussion above about EDSLs. If you don’t feel that supporting EDSLs in this way is important, can you elaborate on why you don’t?

Regarding trailing commas, this is something I also very much want to see. I want my multiline lists to have consistent lines, either commas or no commas. This looks cleaner and makes editing easier.

2 Likes