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

Joe Groff jgroff at apple.com
Thu May 12 18:50:37 CDT 2016


> On May 12, 2016, at 4:47 PM, Chris Lattner <clattner at apple.com> wrote:
> 
> On May 11, 2016, at 9:47 AM, Joe Groff <jgroff at apple.com> wrote:
>> +1 from me. We should be consistent in either accepting or rejecting trailing commas everywhere we have comma-delimited syntax. I'm in favor of accepting it, since it's popular in languages where it's supported to enable a minimal-diff style, so that changes to code don't impact neighboring lines for purely syntactic reasons. If you add an argument to a function, without trailing comma support, a comma has to be added to dirty the previous line:
>> 
>> 	--- a.swift
>> 	+++ a.swift
>> 	 foo(
>> 	   x: 0,
>> 	-  y: 1
>> 	+  y: 1,
>> 	+  z: 2
>> 	 )
>> 
>> Trailing commas avoid this:
>> 
>> 	--- a.swift
>> 	+++ a.swift
>> 	 foo(
>> 	   x: 0,
>> 	   y: 1,
>> 	+  z: 2,
>> 	 )
> 
> You’re arguing that you want to read Swift code written like this?

I wouldn't mind it. The standard library already uses this style for function parameters, modulo the trailing comma, and I certainly prefer it to:
	
> 	--- a.swift
> 	+++ a.swift
> 	 foo( x: 0
> 	    , y: 1
> 	+   , z: 2
> 	    )

-Joe


More information about the swift-evolution mailing list