SE-0250: Swift Code Style Guidelines and Formatter

I think this meta-proposal doesn't answer enough questions. But I certainly have concerns.

The ability to blend imperative, functional and mini-DSL styles is one of the biggest strengths of Swift as a modern hybrid language. Swift is not a minimalist, one-size-fits-all language like Go; pursuing a single global style would be a bad move and readability would suffer. Consider...

// Declarative
let myModel = MyModel(
   Configuration(
      a
   )
)

// Imperative
let myTableCell = MyTableCell()
myTableCell.configure(a)

// Reactive/fluent
let myDataStream = MyService()
   .configure(a)

The differences between these is not purely formatting but formatting is an essential part of each style. Having these multiple coding styles in one codebase helps. It communicates design patterns and intent through visual structure, even when there are no differences in the syntax or types involved.

And look, maybe the planned scope of swift-format is just to fix the most glaringly obvious mistakes like accidental double spaces or missing spaces around braces, while not really doing any reformatting of statement structures. In that case... whatever.

But if swift-format dooms pattern-specific styles like these, it will be a serious loss to readability.

27 Likes