[swift-evolution] [Guidelines, First Argument Labels]: Prepositions inside the parens

Jessy Catterwaul mr.jessy at gmail.com
Tue Feb 9 13:43:12 CST 2016


That seems good, except…
>   2. The method is a factory method; such calls should mirror
>      initializers, with no preposition.  For example,
>      ```
>      let x = UIColor(red: r, green: g, blue: b)
>      let y = monitor.makeColor(red: r, green: g, blue: b)

I disagree with this. I believe that PascalCase for pseudo-initializers is more meaningful and modern than “make…”.

Because the compiler can’t yet deal with this…

protocol Monitor {
   typealias Color
   func Color(red: Float, green: Float, blue: Float) -> Color
}
let color = monitor.Color(red: r, green: g, blue: b)

… I hack around it with this…
func Color_init(red: Float, green: Float, blue: Float) -> Color

…but most of the time, the “_init” is not necessary. Normally we can just namespace out way out of the collision:
protocol Frog {}; extension Frog {
   func String() -> Swift.String {
      return "Frog"
   }
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160209/6723ac0a/attachment.html>


More information about the swift-evolution mailing list