<div dir="ltr">I agree with everything Brent just said.<div>My question would then be: how does this extend?</div><div><br></div><div>Continuing the example:</div><div>'typealias ViewControllerTableViewDataSource = all<UIViewController, UITableViewDataSource>'</div><div><br></div><div>It should then be possible to have a subtype of this which also conforms to UITableViewDelegate.</div><div>So, given the above, this would work:</div><div>'typealias ViewControllerTableViewPackage = all<UIViewController, UITableViewDataSource, UITableViewDelegate>'.</div><div>Would this also work?</div><div>'typealias ViewControllerTableViewPackage = all<ViewControllerTableViewDataSource, UITableViewDelegate>'<br></div><div>Assuming someone defined this typealias: 'typealias TableViewPackage = protocol<UITableViewDataSource, UITableViewDelegate>', would the above also be equivalent to this?:</div><div>'typealias ViewControllerTableViewPackage = all<UIViewController, TableViewPackage>'</div><div><br></div><div>The TableViewPackage protocol, defined above, is considered by Swift to be a 'non-nominal type'. Thus this is illegal:</div><div>'extension TableViewPackage'</div><div>(I don't know why. Perhaps a type conforming to the separate protocols has to opt-in to the combination?)</div><div><br></div><div>However, we can have the following:<br></div><div>'extension UITableViewDelegate where Self : UITableViewDataSource'</div><div>'extension UITableViewDelegate where Self : UIViewController'</div><div>'extension UITableViewDelegate where Self : UIViewController, Self : UITableViewDataSource'</div><div><br></div><div>Similarly we can't currently have this:</div><div>'extension UIViewController where Self : UITableViewDataSource, UITableViewDelegate'</div><div>because UIViewController is not a generic type (and this is part of the original complaint).</div><div><br></div><div>It would be nice to be able to write this out as: 'extension all<UIViewController, UITableViewDataSource, UITableViewDelegate>', even if it's just syntactic sugar for 'extension UITableViewDelegate where Self : UIViewController, Self : UITableViewDataSource'.</div><div><br></div><div>-- Ross</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 10, 2016 at 1:44 PM, Maximilian Hünenberger <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">In the thread "Partially constrained protocols" we have discussed a similar approach using where clauses:<br>
<br>
protocol<MyProtocol where Self: UIViewController><br>
<br>
- Maximilian<br>
<div class="HOEnZb"><div class="h5"><br>
Am 10.02.2016 um 14:00 schrieb Brent Royal-Gordon via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>>:<br>
<br>
>> So, I definitely think there is room for improvement here… how about recycling the inheritance syntax?<br>
>><br>
>> let controller: (UIViewController, UITableViewDatasource)<br>
><br>
> This declares a tuple containing a UIViewController and a UITableViewDataSource.<br>
><br>
>> 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<br>
>><br>
>> let controller: Optional<UIViewController, UITableViewDatasource><br>
><br>
> This attempts to declare an optional with two generic types, which doesn't work because Optional only has one type parameter. (But other types, like Dictionary, *do* take two type parameters.)<br>
><br>
> Swift does already have a syntax for declaring that a type must conform to two (or more!) protocols:<br>
><br>
> let controller: protocol<UITableViewDataSource, UITableViewDelegate><br>
><br>
> I think this could probably be extended to support one class type as well, perhaps with a new name:<br>
><br>
> let controller: all<UIViewController, UITableViewDataSource><br>
><br>
> --<br>
> Brent Royal-Gordon<br>
> Architechies<br>
><br>
> _______________________________________________<br>
> swift-evolution mailing list<br>
> <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
> <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</div></div></blockquote></div><br></div>