Allow trailing comma in guard, if-let, et al

Is there any reason Swift can't allow a trailing comma in constructs like this:

guard
    let a = ...,
    let b = ...,
    let c = ...,
else
{
}

doing so makes it a bit easier to rearrange lines, and is similar to the trailing comma allowed inside array and dictionary definitions:

let a = [ 1, 2, 3, ]

TIA,

···

--
Rick Mann
rmann@latencyzero.com

A similar proposal was rejected:

<https://lists.swift.org/pipermail/swift-evolution-announce/2016-May/000171.html&gt;

-- Ben

···

On 18 Aug 2016, at 00:13, Rick Mann wrote:

Is there any reason Swift can't allow a trailing comma in constructs like this:

guard
   let a = ...,
   let b = ...,
   let c = ...,
else
{
}

doing so makes it a bit easier to rearrange lines, and is similar to the trailing comma allowed inside array and dictionary definitions:

let a = [ 1, 2, 3, ]

Thanks. Hmm. The stated arguments seem to apply to tuples and parameter lists, not variable bindings.

···

On Aug 17, 2016, at 18:11 , Ben Rimmington <me@benrimmington.com> wrote:

On 18 Aug 2016, at 00:13, Rick Mann wrote:

Is there any reason Swift can't allow a trailing comma in constructs like this:

guard
  let a = ...,
  let b = ...,
  let c = ...,
else
{
}

doing so makes it a bit easier to rearrange lines, and is similar to the trailing comma allowed inside array and dictionary definitions:

let a = [ 1, 2, 3, ]

A similar proposal was rejected:

<https://lists.swift.org/pipermail/swift-evolution-announce/2016-May/000171.html&gt;

--
Rick Mann
rmann@latencyzero.com

Guard wouldn't work, because the "else" is usually on the same line as the last element.

Perhaps the answer is better commenting in IDEs? So if you select a region and hit CMD+/ Xcode will comment with /*...*/ instead of sticking a // in front of the whole line.

Perhaps it could auto-expand to the complete clause if you select most of a clause in a multi-clause condition?

Karl

···

Sent from my new Email (‎Email - Edison Mail on the App Store)

On Aug 19, 2016 at 1:21 am, <Rick Mann via swift-evolution (mailto:swift-evolution@swift.org)> wrote:

> On Aug 17, 2016, at 18:11 , Ben Rimmington <me@benrimmington.com (mailto:me@benrimmington.com)> wrote:
>
>
>> On 18 Aug 2016, at 00:13, Rick Mann wrote:
>>
>> Is there any reason Swift can't allow a trailing comma in constructs like this:
>>
>> guard
>> let a = ...,
>> let b = ...,
>> let c = ...,
>> else
>> {
>> }
>>
>> doing so makes it a bit easier to rearrange lines, and is similar to the trailing comma allowed inside array and dictionary definitions:
>>
>> let a = [ 1, 2, 3, ]
>
> A similar proposal was rejected:
>
> <https://lists.swift.org/pipermail/swift-evolution-announce/2016-May/000171.html&gt;

Thanks. Hmm. The stated arguments seem to apply to tuples and parameter lists, not variable bindings.

--
Rick Mann
rmann@latencyzero.com

_______________________________________________
swift-evolution mailing list (mailto:listswift-evolution@swift.orghttps)
swift-evolution@swift.org (mailto:listswift-evolution@swift.orghttps)
https (mailto:listswift-evolution@swift.orghttps)://lists.swift.org/mailman/listinfo/swift-evolution

Guard wouldn't work, because the "else" is usually on the same line as the last element.

Not in my coding style.

Perhaps the answer is better commenting in IDEs? So if you select a region and hit CMD+/ Xcode will comment with /*...*/ instead of sticking a // in front of the whole line.

I hate having to rely on an editor to have features implemented to work around inconveniences in the language. Having said that, it's the fairly standard macOS behavior of triple-clicking to select an entire line, and then dragging up or down, that prompts some of my coding style (that encourages things to be on their own line).

Fitz's law means it's a lot easier to triple-click and select a whole line than it is to select just part of a line.

···

On Aug 19, 2016, at 10:26 , Karl Wagner <razielim@gmail.com> wrote:

Perhaps it could auto-expand to the complete clause if you select most of a clause in a multi-clause condition?

Karl

Sent from my new Email

On Aug 19, 2016 at 1:21 am, <Rick Mann via swift-evolution> wrote:

> On Aug 17, 2016, at 18:11 , Ben Rimmington <me@benrimmington.com> wrote:
>
>
>> On 18 Aug 2016, at 00:13, Rick Mann wrote:
>>
>> Is there any reason Swift can't allow a trailing comma in constructs like this:
>>
>> guard
>> let a = ...,
>> let b = ...,
>> let c = ...,
>> else
>> {
>> }
>>
>> doing so makes it a bit easier to rearrange lines, and is similar to the trailing comma allowed inside array and dictionary definitions:
>>
>> let a = [ 1, 2, 3, ]
>
> A similar proposal was rejected:
>
> <https://lists.swift.org/pipermail/swift-evolution-announce/2016-May/000171.html&gt;

Thanks. Hmm. The stated arguments seem to apply to tuples and parameter lists, not variable bindings.

--
Rick Mann
rmann@latencyzero.com

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

--
Rick Mann
rmann@latencyzero.com