[swift-evolution] [Proposal] Make optional protocol methods first class citizens
andrey at tarantsov.com
Wed Mar 30 21:42:28 CDT 2016
I'm missing those optional methods too, but protocol extensions sound like a better solution for this.
(For those suggesting a separate protocol, consider UITableView. How many protocols would it take to model all the optional delegate methods as separate protocols? Certainly more than 10, perhaps a few dozen.)
I would welcome a standardized way to document the methods as optional-to-implement, though, beyond just requiring a protocol extension. My ideal option would be to allow the optional keyword and change it to simply require a default implementation in a protocol extension.
If we don't want a language change, then perhaps a conventional doc tag?
> On Mar 30, 2016, at 8:08 PM, Yuval Tal via swift-evolution <swift-evolution at swift.org> wrote:
> 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,
> swift-evolution mailing list
> swift-evolution at swift.org
More information about the swift-evolution