[swift-evolution] Specify type of a delegate which conforms to a protocol

Tino Heth 2th at gmx.de
Wed Feb 10 05:43:29 CST 2016


The way to declare conformance to multiple protocols always seemed odd to me:

- It looks like protocol is a generic class, but generics always have a fixed number of parameters
- By convention, all types have to start with uppercase (besides protocol, there is at least another exception: Restricting protocols to reference types via "class")

So, I definitely think there is room for improvement hereā€¦ how about recycling the inheritance syntax?

let controller: (UIViewController, UITableViewDatasource)

I added the braces because it would be really when you add the question mark for an optional value; an alternative for this case would be

let controller: Optional<UIViewController, UITableViewDatasource>

Tino


More information about the swift-evolution mailing list