[swift-evolution] Proposal: Change of syntax for class protocols

Matthew Cheok hello at matthewcheok.com
Mon Dec 7 10:00:16 CST 2015

Currently, we declare class protocols with the following syntax:

protocol TestProtocol: class, OtherProtocol {}

This is odd for a few reasons:
1) The keyword class exists in the middle of the declaration
2) The keyword class follows the colon and looks a lot like inheritance
3) The keyword class occupies a somewhat arbitrary first position after the colon (otherwise we have an error)

We also have another use of the class keyword as a modifier when declaring class methods:

class func doSomething() {}

I’m suggesting a change of syntax that rectifies the above issues:

class protocol TestProtocol: OtherProtocol {}

Would love to hear other thoughts on this.

- Matthew

More information about the swift-evolution mailing list