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

Joanna Carter joanna at carterconsulting.org.uk
Sun Mar 5 06:21:50 CST 2017


> 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



More information about the swift-evolution mailing list