[swift-evolution] [Proposal] Make optional protocol methods first class citizens

Adrian Kashivskyy adrian.kashivskyy at me.com
Thu Mar 31 16:21:21 CDT 2016


I think it's a bad idea because current model (with no optional methods) encourages decomposing protocols into smaller ones, thus discouraging partial functions and making our code safer and more predictable.

In my opinion, right now, if you really need an optional protocol method, consider adding a default implementation for it. You'd be surprised how often it's enough to satisfy the need for an optional method.


Regards,
Adrian Kashivskyy

> Wiadomość napisana przez Yuval Tal via swift-evolution <swift-evolution at swift.org> w dniu 30.03.2016, o godz. 16:08:
> 
> Hi,
> 
> I find that optional protocol methods to be very useful. However, there is a caveat -- it needs to be mapped to @objc. This puts a set of limitations, such as: structures cannot be used as parameters as it does not map to objective-c. What do you think about removing the requirement of using @objc and allow to create optional methods without these limitations?
> 
> Thank you,
> 
> -Yuval
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

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


More information about the swift-evolution mailing list