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

Gwendal Roué gwendal.roue at gmail.com
Fri May 13 00:58:42 CDT 2016


> Le 13 mai 2016 à 07:01, Chris Lattner via swift-evolution <swift-evolution at swift.org> a écrit :
> 
> On May 12, 2016, at 4:50 PM, Joe Groff <jgroff at apple.com> wrote:
>>>> 	--- 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.
> 
> I personally find that style repulsive :-) and I haven’t seen swift code commonly doing it.  I’m not sure that we want to encourage it either.

Don't be too harsh :-) This style can be used with much profit when there are several closure arguments:

	foo(
	    x: {
	        // several lines of code
	    },
	    y: {
	        // several lines of code
	    }
	)

For example: https://github.com/groue/GRDBDemo/blob/cd8b9d5cadc3c6c66fd0da4869d820c6624fdf79/GRDBDemo/PersonsViewController.swift#L12-L44

Gwendal Roué



More information about the swift-evolution mailing list