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

Chris Lattner clattner at apple.com
Tue May 10 15:58:52 CDT 2016

> On May 10, 2016, at 12:36 PM, Tony Allevato <allevato at google.com> wrote:
> On Tue, May 10, 2016 at 11:53 AM Chris Lattner via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
> Hello Swift community,
> The review of "SE-0084: Allow trailing commas in parameter lists and tuples" begins now and runs through May 16. The proposal is available here:
>         https://github.com/apple/swift-evolution/blob/master/proposals/0084-trailing-commas.md <https://github.com/apple/swift-evolution/blob/master/proposals/0084-trailing-commas.md>
>         * What is your evaluation of the proposal?
> -1. It makes more sense to allow this for arrays and dictionaries because are variable-length collections whose literals are much more likely to grow as a code base evolves (anecdotal personal experience). Tuples are fixed arity, so proactively protecting oneself with a trailing comma seems like it would have minimal benefit when the surrounding code would have to change in other ways.
> Likewise for function calls; I would argue that if a function call/definition's parameter list is likely to grow so much and/or so frequently that a trailing comma provides significant savings, that's a code smell that should encourage the author to redesign the function.

FWIW, I personally agree with this observation.

Parameter lists and tuples are also structurally different than collections.  Parameter lists also have labels, and (depending on how the ‘disable reordering default arguments’ decision goes) parameters may not be added and reordered arbitrarily.  Tuples are different because adding a member will often break all the code downstream because it changes the type of the value.  This is different than array and dictionary literals.

The only “collection like” aspect I can think of is for variadic parameter lists, but I don’t think they’re common enough to provide a special case for.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160510/f887f140/attachment.html>

More information about the swift-evolution mailing list