Treat commas as whitespace in dictionary and array literals

Originator:alexisgallagher
Number:rdar://17288172 Date Originated:2014-06-12
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode6-Beta
Classification: Reproducible:
 
Summary:

I applaud that Swift has done away with unnecessary semicolons, treating them as whitespace. I also think it's great that it's done away with requiring unnecessary parentheses in conditional contexts.

I think it would be great if it took the next logical and did away with requiring unnecessary commas in dictionary and array literal contexts, treating them as whitespace as well.

So instead of writing

   var example = [1, 2, 3, 4]

you could just write

   var example = [1 2 3 4]

And instead of writing

   var my dictionary = ["a":1, "b":2, "c":3]

you could just write

   var my dictionary = ["a":1 "b":2 "c":3]

This is a cleaner syntax.

Spaces are a better default separator, which is why we use them as the separators between written words every day, instead,of,writing,every,sentence,like,this,which,is,hard,to,read,and,annoying!  Also, we are *already* writing spaces to separate collection items, so writing commas as well is just adding line noise. We are not adding obscure, meaningful punctuation; we are getting rid of obscuring, meaningless punctuation. As our colleagues in design remind us, whitespace is good.

(The Clojure language already works this way, by the way, and it's worked for years without difficulties.)

Of course, since we can just treat the comma as whitespace, no one would be required to write in this way immediately. Traditionalists could cleave to the familiar comfort of unnecessary commas, unnecessary semicolons, and unnecessary parentheses, so they would not be alarmed or inconvenienced.

Steps to Reproduce:
Write an array or dictionary in the cleanest possible syntax

Expected Results:
glorious compilation

Actual Results:
inglorious compilation error.

Version:
Xcode6-beta

Notes:


Configuration:
all the time

Attachments:

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!