[swift-evolution] [Rejected] SE-0084: Allow trailing commas in parameter lists and tuples

Erica Sadun erica at ericasadun.com
Wed May 25 22:46:48 CDT 2016


> On May 25, 2016, at 9:37 PM, Chris Lattner via swift-evolution <swift-evolution at swift.org> wrote:
> Swift currently accepts a trailing comma in array and dictionary collection literals, for three reasons:  evolution of a project often adds and removes elements to the collection over time, these changes do not alter the type of the collection (so those changes are typically spot changes), and the closing sigil of the collection (a right square bracket) is often placed on the line *following* the elements of the collection.  Because of these properties, accepting a trailing comma in a collection literal can help reduce spurious diffs when elements are added or removed.
> 
> That said, these properties do not translate to other comma separated lists in Swift, such as variable bindings in a var/let declaration, parameter lists or tuples.  For parameter lists and tuples (the specific topic of the proposal), the trailing terminator of the list is typically placed on the same line as the other elements.  Further, changes to add or remove an element to a parameter list or tuple element list change the type of the tuple or the signature of the call, meaning that there is almost always changes in other parts of the code to allow the change to build.  Finally, the core team does not want to encourage or endorse a coding style that puts the terminating right parenthesis on a line following the arguments to that call.


To be honest, I was hoping the core team might agree that they be allowed just at call-sites, where changes would not propagate to other parts of the code but allow the easy inclusion and exclusion of defaulted arguments. 

Sad to see this one go down but gratified that it got a fair consideration. Thank you again, -- E



More information about the swift-evolution mailing list