[swift-evolution] [swift-evolution-announce] [Review] SE-0084: Allow trailing commas in parameter lists and tuples
Vladimir.S
svabox at gmail.com
Thu May 12 02:19:03 CDT 2016
On 12.05.2016 5:28, Ricardo Parada via swift-evolution wrote:
> I would support the trailing comma so that the language is consistent but I
> don't think I would personally use it.
IMO language will be consistent (regarding trailing comma) if we extend the
proposal to *any comma-separated list* in Swift.. like list of generic
types <T,U,V,>.
So, I'd understand if Swift will allow(or better - *require*) trailing
comma in *any* such list. Or just for array/dict. But not for some piece of
code(func params, tuples), but not for other(list of generics or other)
And I don't accept the problem with diffs - yes, diff will show you not
just new element is added, but also that element that was last is not last
anymore.
Also, often closed `)` is placed on the same line with last parameter:
func myFunc(a: Int,
b: String,
c: Int,) {
}
so after we add `d` parameter:
func myFunc(a: Int,
b: String,
c: Int,
d: String) {
}
the diff will show not only new `d` declaration, but also changes to `c`
line even with trailing comma.
IMO when I write function(code), I usually don't expect it will have more
arguments. When I write array/dict initialization(data), I usually expect
to add more items to it.
So I'm strongly -1 on this proposal in any case. At least we should extend
it to allow trailing comma in any list. And I then (if this is so pretty
feature) prefer Swift to require that trailing comma in list. This will be
consistent and strict.
More information about the swift-evolution
mailing list