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

Dave Abrahams dabrahams at apple.com
Thu Mar 31 13:23:28 CDT 2016


on Wed Mar 30 2016, Yuval Tal <swift-evolution at swift.org> wrote:

> 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?

Caveat: this is going to be strongly-worded; sorry in advance.  I think
(no offense intended) it's a terrible idea.  The whole notion of an
“optional requirement” is nonsensical to begin with, and the use of
optional protocol requirements encourages a style of programming that
lifts the responsibility of the protocol designer for careful design at
the expense of clients of the protocol.  There are better ways to do
things; let's not propagate this anti-pattern any further than it's
already gone.

-- 
Dave



More information about the swift-evolution mailing list