[swift-evolution] [Pitch] Requiring proactive overrides for default protocol implementations.
scanon at apple.com
Fri Apr 29 10:44:27 CDT 2016
> On Apr 29, 2016, at 10:38 AM, Xiaodi Wu via swift-evolution <swift-evolution at swift.org> wrote:
> I'd be keenly interested in something that would improve the experience of conforming a type to a protocol. I think others would as well. A sufficiently sophisticated solution would:
> * catch unintentional typos that cause required functions to be incorrectly named
> * show, ideally prospectively, which required functions have default implementations
> * clarify (and this is obviously a cherry-on-top scenario) what protocol requirements any particular function helps to satisfy as well as which combination of implementations is used to synthesize a default implementation of another function (e.g. <= synthesized from < and ==; this would help to determine whether it might be more efficient to roll your own override)
> * support all retroactive modeling scenarios currently supported
> I tried to propose a keyword-based solution (less sophisticated than yours) a while back, and I've been convinced that the drawbacks in terms of decreased expressiveness in retroactive modeling might be insurmountable. Perhaps it would be worthwhile exploring improvements in tooling and documentation (including annotation of the code itself) in order to address some of these areas?
Yeah, I think this is something that tooling / editors could really help with. I would love it if when I typed:
struct Foo: Bar
extension Foo: Bar
a skeleton with the missing Bar APIs was auto-generated for me to fill in. This would make it much easier to get conformances right, and require less typing instead of more.
More information about the swift-evolution