[swift-evolution] Allowing trailing commas in argument lists

Patrick Gili gili.patrick.r at gili-labs.com
Thu Mar 10 15:13:18 CST 2016

Hi Erica,

I disagree that trailing commas can lead to unsafe code. What if I'm coding the initialization of an array or dictionary, I'm interrupted, and I forget to go back and finish it. There's a trailing command left dangling in the initialization code. Today, the compiler warns me, I go back and have an "aha moment', fix the code, and everyone is happy. If we allow trailing commands, the compiler never warns me, I'm left with unfinished initialization code, it builds anyways, and I have a bad day.


> On Mar 10, 2016, at 3:27 PM, Erica Sadun via swift-evolution <swift-evolution at swift.org> wrote:
>>>> On 10 Mar 2016, at 17:28, Radosław Pietruszewski <radexpl at gmail.com <mailto:radexpl at gmail.com>> wrote:
>>>> Trailing comma is not nonsensical, there is a specific purpose in allowing it (unlike your examples), and there’s precedent in Swift already.
> Trailing commas enable easier re-ordering of arguments, simplify growing or compacting argument lists, and do no harm.
> Their use in arrays and dictionaries are conventional enough that experienced programmers will not be surprised by their
> presence. No one will force their use and one's internal style guide (and linters) can direct whether any individual group
> adopts or ignores the addition.
> For those of us who prefer trailing commas, it will be both a convenience and an asset. For those against, there's no harm
> done. I find it unlikely that trailing commas will naturally lead to any unsafe code or produce a net negative effect on the
> language or the code-base it supports.
> -- Erica
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

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

More information about the swift-evolution mailing list