[swift-evolution] [Pitch] merge types and protocols back together with type<Type, Protocol, ...>

Ross O'Brien narrativium+swift at gmail.com
Fri May 13 12:11:11 CDT 2016


In reply to:

Why would you want to add all of these different formats where only one
could serve them all. This is redundant in my opinion.

`struct<>` and `enum<>` would have same rules, only the first element would
be a different value-type. I might consider this as an alternative.

Correct me if I’m wrong with the redundancy.


'enum<>' might be valid, unless their functions (e.g. for 'init(rawValue:
Int)' or 'allCases') are declared in explicit protocols which would
implicitly cover enums and which other types could declare conformance to.

'struct<>' does seem redundant unless it becomes subtypeable. If you want a
struct which conforms to several protocols, protocol<> already covers this.
I know there's a discussion at the moment regarding the equivalent of an
'AnyObject' for value types, which might apply to this discussion, but I'm
not sure how.

A class in general would also a protocol<AnyObject, ...>. The benefit of
'type<>' is in its ability to extend the behaviours of several subclasses
at once, e.g. type<UIViewController, UIScrollViewDelegate> covers all view
controllers with scroll views, not just UITableViewController,
UICollectionViewController, etc..



​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160513/4ace2772/attachment.html>


More information about the swift-evolution mailing list