[swift-evolution] class indent in swift, history?

Chris Lattner clattner at nondot.org
Wed Mar 8 23:25:18 CST 2017


> On Mar 8, 2017, at 12:35 AM, Adrian Zubarev <adrian.zubarev at devandartist.com> wrote:
> 
> The latter slightly confused me for a second and I had to double check. You’re saying that cases are not indented “because” they are part of the switch statement, but observers like willSet and didSet are indented even if they are part of the property they are defined on. What’s the point I’m missing in this argument? (I’m precisely talking about the comparison between cases and observers, not about the indent elsewhere.)
> 

I was confused by an apparent bug in SourceKit.  It looks like top level properties are indented like this:

var zzd : Int = 12 {
didSet {
  print(42)
}
}

But that didSet/willSet are indented when inside of a class:

  var zzd : Int = 12 {
    didSet {
      print(42)
    }
  }

This should clearly be consistent, and the second is the right way to do it, but this behavior invalidates my argument.  The new argument I’d make is that things with braces should definitely be indented :-).  I retain the argument that cases are “part of” the switch statement itself.

-Chris

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170308/83a9672b/attachment.html>


More information about the swift-evolution mailing list