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

Dany St-Amant dsa.mls at icloud.com
Tue May 10 19:51:32 CDT 2016


> On May 10, 2016, at 4:57 PM, Rob Napier via swift-evolution <swift-evolution at swift.org> wrote:
> 
>> On Tue, May 10, 2016 at 2:53 PM, Chris Lattner via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>>         * What is your evaluation of the proposal?
> 
> Trailing commas is clearly very useful in the collections case. While that case is more common than functions and tuples, I don't see any reason that collections should be treated as a special case. Why should some comma-separated lists allow trailing commas and some not?
> 
> This seems a reasonable move towards consistency and is useful in some cases while not harmful in others. When in doubt, I'd rather broad rules ("trailing commas are allowed in comma-separated lists") rather than special cases. This improves teachability.

If one look purely at commas, the inconsistency may be hard to explain, but if one include the enclosing characters there are clear rules:

- within square brackets: trailing comma allowed
- within parenthesis: trailing comma not allowed
- within angle bracket: trailing comma not allowed

Weird, I do not recall anyone mentioning generics in the original trailing comma thread.

Dany

> 
> It also improves diffs when functions pick up new parameters, particularly ones with default values. This is particularly common (and expected) in constructors. That's valuable.
> 
>  
>>         * Is the problem being addressed significant enough to warrant a change to Swift?
> 
> As a language rule simplification, I believe it's worth a change if it doesn't introduce problematic corner cases. The fact that it improves diffs is no less valuable for functions than it is for collections.
> 
>  
>>         * Does this proposal fit well with the feel and direction of Swift?
> 
> Yes; it definitely feels Swifty in the same way that it does for collections. There's no reason for Swift to treat them differently.
> 
>  
>>         * If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
> 
> I've seen this in Perl, Python, and Go. Basically every language I've used that allows trailing commas in collections also allows them in function calls. In Go, the trailing comma is mandatory in some cases. This has been nice for consistency.
> 
>  
>>         * How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
> 
> Quick reading.
> 
> -Rob
> 
> _______________________________________________
> 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/20160510/870aa1e6/attachment.html>


More information about the swift-evolution mailing list