[swift-evolution] Keyword for protocol conformance

Charles Srstka cocoadev at charlessoft.com
Mon Aug 22 17:30:11 CDT 2016


> On Aug 22, 2016, at 5:19 PM, Xiaodi Wu via swift-evolution <swift-evolution at swift.org> wrote:
> 
> This has been proposed before in the past by several others (myself being one of them).
> 
> The key problem is that it cannot accommodate retroactive modeling. That is, you would not be able to conform existing types, the code for which you do not control, to a protocol of your own design. Retroactive modeling is an essential feature of Swift protocol-oriented programming.

Then how about making the keyword optional? A method or property with the keyword before it would throw an error if it didn’t exist in one of the protocols your type implements. This way, if you intended a method to satisfy a protocol but left a typo in it, or you changed the protocol’s signature in a refactoring or something, you’d get notified instead of not finding out about it until runtime.

Charles

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160822/56103cd0/attachment.html>


More information about the swift-evolution mailing list