Ben_Cohen
(Ben Cohen)
November 29, 2023, 5:10am
41
supervillain:
In the spirit of simplifying the syntax, in the same way that the semi-colon was removed as a line terminator, it could also be "nice" to just omit the comma as a separator for multi-line parameters, including arrays and dictionaries.
This is SE-0257 which was returned for revision due to some (unfortunately fairly tough to overcome) parsing ambiguities. Personally, I agree it would be really nice.
2 Likes
mesqueeb
(mesqueeb)
October 10, 2024, 11:20pm
42
I just want to add my vote to allowing trailing commas in the same places as JavaScript allows them. In the spirit of attracting new developers to the Swift ecosystem with the least friction possible.
Also, it's not because you can add trailing comma's in function parameters, that you are forced to. So why not allow it for the rest of us who want it. : )
In case anyone stumbles on this without knowing if it was implemented; it was!
# Allow trailing comma in comma-separated lists
* Proposal: [SE-0439](0439-trailing-comma-lists.md)
* Author: [Mateus Rodrigues](https://github.com/mateusrodriguesxyz)
* Review Manager: [Xiaodi Wu](https://github.com/xwu)
* Status: **Implemented (Swift 6.1)**
* Implementation: [swiftlang/swift#74522](https://github.com/swiftlang/swift/pull/74522)
* Previous Proposal: [SE-0084](0084-trailing-commas.md)
* Review: ([pitch](https://forums.swift.org/t/pitch-allow-trailing-comma-in-tuples-arguments-and-if-guard-while-conditions/70170)), ([review](https://forums.swift.org/t/se-0439-allow-trailing-comma-in-comma-separated-lists/72876)), ([acceptance](https://forums.swift.org/t/accepted-with-modifications-se-0439-allow-trailing-comma-in-comma-separated-lists/73216))
* Previous Revision: ([1](https://github.com/swiftlang/swift-evolution/blob/7864fa20cfb3a43aa6874feedb5aedb8be02da2c/proposals/0439-trailing-comma-lists.md))
## Introduction
This proposal aims to allow the use of trailing commas, currently restricted to array and dictionary literals, in symmetrically delimited comma-separated lists.
## Motivation
### Development Quality of Life Improvement
A trailing comma is an optional comma after the last item in a list of elements:
This file has been truncated. show original
4 Likes