[swift-evolution] [Pitch] Non-class type requirements on protocols (eg : struct, : enum)
Mike Kasianowicz
mike at ap14.com
Fri Oct 21 01:39:06 CDT 2016
Currently protocols can have the class constraint:
protocol MyProtocol : class {}
It would be (a) intuitive and (b) useful to allow such things as:
protocol Model : struct {} or protocol Event : enum {}
These types of restrictions can help prevent accidental anti-patterns or
misuse of APIs.
Seems simple and non-controversial... right?
[Note: I'd like to see even more heavy-handed protocol restrictions in the
future. For example, a protocol describing an enum with a common case, or
a struct with no reference members. Great stuff for defensively coding
APIs.]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161021/d3c98459/attachment.html>
More information about the swift-evolution
mailing list