[swift-evolution] [Proposal][Discussion] Modular Swift

Robert Widmann devteam.codafi at gmail.com
Sun Mar 5 21:38:22 CST 2017


A lot of “Swift Style” is “LLVM Style” enforced in little corners of the language (I, too, like to keep my cases indented a bit further).  There are formatting tools available to make your Swift look C#-ish if you want :)

> On Mar 5, 2017, at 7:21 AM, Joanna Carter via swift-evolution <swift-evolution at swift.org> wrote:
> 
>> It's part of what has become Swift style and I'm quite happy about it. Indent on case and on case content is too much indenting :)
>> 
>>> On 3 Mar 2017, at 11:06, Karl Wagner via swift-evolution <swift-evolution at swift.org> wrote:
>>> 
>>> 
>>>> On 3 Mar 2017, at 05:52, T.J. Usiyan via swift-evolution <swift-evolution at swift.org> wrote:
>>>> 
>>>> I would rather that we use the (not-entirely-pleasant-to-me) "curly brace without an indent" used for switches+cases.  
>>> 
>>> Is that actually “how we do things in Swift”? I always thought it was just Xcode being silly…
>>> 
>>> I should probably file a radar about it in either case.
> 
> I have to say, I really *hate* "Swift style". It wouldn't be so bad if I could change the indentation rules in Xcode.
> 
> For over 25 years, I have written code with curly braces always on their own line, opening ones aligned with the start of the preceding line.
> 
> As for switch..case statement indenting, the default supplied by code completion is laid ou thus :
> 
>    switch value {
>    case pattern:
>      code
>    default:
>      code
>    }
> 
> Whereas, for Objective-C, code completion gives us :
> 
>    switch (value) {
>      case pattern:
>        code
>        break;
> 
>      default:
>        break;
>    }
> 
> With Objective-C, all I had to do was move the opening curly brace to the next line and Xcode would keep the same indentation :
> 
>    switch (value)
>    {
>      case pattern:
>        code
>        break;
> 
>      default:
>        break;
>    }
> 
> Now, in Swift, not only do I not have the ability to group lines of code together with braces (interpreted as a closure), if I move the opening brace to the next line and indent the cases (for clarity) :
> 
>    switch value
>    {
>      case pattern:
>        code
>      default:
>        code
>    }
> 
> … although the opening brace stays put, as soon as I reformat a block of code that includes the switch, I automatically lose the indentation of my cases!
> 
> And, no matter what I do in Xcode preferences, I don't seem to be able to achieve *my* coding standards for Swift.
> 
> There are days when I feel like reverting to Objective-C
> 
> --
> Joanna Carter
> Carter Consulting
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list