<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I see the following an advantage of using trailing commas:<div class=""><br class=""></div><div class="">If using trailing commas, when adding an item at the end of array, only one line has to be changed (added). If not, two lines are diffed (comma + new element).</div><div class=""><br class=""></div><div class="">So yeah, +1. Because Why Not™. ¯\_(ツ)_/¯</div><div class=""><br class=""><div class="">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><font color="#929292" class=""><br class="Apple-interchange-newline">Pozdrawiam – Regards,</font></div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><font color="#929292" class="">Adrian Kashivskyy</font></div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">Wiadomość napisana przez Radosław Pietruszewski via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> w dniu 09.03.2016, o godz. 15:02:</div><br class="Apple-interchange-newline"><div class=""><div class="">JavaScript’s common convention (and weird looking!) to use leading commas is exactly because it can’t do trailing commas.<br class=""><br class="">Swift already allows trailing commas in arrays. Even if not everyone will know or use this, I see zero harm in allowing trailing commas in argument lists and tuples.<br class=""><br class="">+1. Because Why Not™.<br class=""><br class="">— Radek<br class=""><br class=""><blockquote type="cite" class="">On 09 Mar 2016, at 13:54, Nisse Bergman via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class="">-1<br class="">Let’s not go down this path and enable the javascript flamewar of trailing or non-trailing commas. <br class=""><br class="">Nisse<br class=""><br class=""><br class=""><br class=""><blockquote type="cite" class="">On 09 Mar 2016, at 01:23, Joe Groff via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class="">Yes please.<br class=""><br class=""><blockquote type="cite" class="">On Mar 8, 2016, at 2:07 PM, Grant Paul via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class="">## Introduction<br class=""><br class="">Right now, Swift argument lists are not permitted to contain trailing commas. To make multi-line calls easier, we propose allowing trailing commas in argument (and tuple) syntax:<br class=""><br class=""> let person = Person(<br class=""> id: json['id'],<br class=""> name: json['name'],<br class=""> picture: Im2age(picture),<br class=""> friends: friends,<br class=""> )<br class=""><br class=""><br class="">## Motivation<br class=""><br class="">It’s common for functions to take a number of arguments. In some languages, this can make it difficult to figure out what a function does, leading to patterns like fluent interfaces and configuration objects.<br class=""><br class="">Swift, by contrast, handles this very well. Argument labels make sure parameters aren’t confused even when they’re of the same type. And compared to Objective-C, it’s much easier to write a multi-line list of arguments in Swift.<br class=""><br class="">However, with a parentheses placement style placing the closing parentheses for a multi-line call on a new line, Swift does not support a trailing comma. Trailing commas have a number of benefits:<br class=""><br class="">- It is easier to re-arrange lines (especially in certain text editors) when all lines have commas. <br class="">- Line-based diffs (as used by most source control systems) only show added lines when adding a new parameter to the end, rather than two lines where one just adds the comma.<br class="">- It’s more consistent with other Swift lists which do support trailing commas.<br class=""><br class=""><br class="">## Proposed Solution<br class=""><br class="">The proposed solution is to allow and ignore trailing commas in argument lists and tuples:<br class=""><br class=""> let person = Person(<br class=""> id: json['id'],<br class=""> name: json['name'],<br class=""> picture: Image(picture),<br class=""> friends: friends,<br class=""> )<br class=""><br class=""> let tuple = (<br class=""> color,<br class=""> 32,<br class=""> )<br class=""><br class=""><br class="">## Detailed Design<br class=""><br class="">Support for trailing commas in argument lists and tuples would make them consistent with Swift’s handling of array literals, which do support trailing commas:<br class=""><br class=""> let array = [<br class=""> 2,<br class=""> 4,<br class=""> 8,<br class=""> ]<br class=""><br class="">There should not be any impact to existing code from this proposal.<br class=""><br class="">Support for this syntax is also found in other programming languages like Python, D, and Hack. It’s been proposed for JavaScript (positive response) and PHP (rejected):<br class=""><br class="">- JavaScript: <a href="https://jeffmo.github.io/es-trailing-function-commas/" class="">https://jeffmo.github.io/es-trailing-function-commas/</a><br class="">- PHP: <a href="https://wiki.php.net/rfc/trailing-comma-function-args" class="">https://wiki.php.net/rfc/trailing-comma-function-args</a><br class=""><br class=""><br class="">## Alternatives Considered<br class=""><br class="">The main alternative is the existing behavior. This has the benefit of standardizing Swift code on a particular style. However, many people will in practice continue to use a style regardless of support trailing commas, especially for cross-language consistency. It could also lead to JavaScript-inspired parameter ordering:<br class=""><br class=""> let person =<br class=""> Person(id: json['id']<br class=""> , name: json['name']<br class=""> , picture: Image(picture)<br class=""> , friends: friends)<br class=""><br class="">Another alternative would be to support this syntax for function parameters but not tuples. However, this would be an arbitrary inconsistency.<br class=""><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></blockquote><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></blockquote><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></blockquote><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></div></blockquote></div><br class=""></div></body></html>