[swift-evolution] Mark protocol methods with their protocol

Dave Abrahams dabrahams at apple.com
Thu Sep 22 13:33:08 CDT 2016


on Thu Sep 22 2016, Martin Waitz <tali-AT-admingilde.org> wrote:

> Hi,
>
> isn't it perfectly fine to conform to multiple unrelated protocols
> which both require the same member?

Yeah, but in practice it *basically* never happens, to the point where
I'd be fine requiring boilerplate repetition if you wanted to satisfy
requirements of two protocols unrelated by refinement with the same
declaration.

> Or to declare protocol conformance in some unrelated module?
>
> Am 2016-09-22 07:15, schrieb Karl via swift-evolution:
>> I would like to make it a requirement if not inside a protocol
>> extension which declares a conformance, and actually build the
>> protocol name in to the member in an ABI-breaking way.
>
> IMO, this is much too restrictive.
> When we force the protocol name into the member, we make it impossible
> to conform to multiple protocols.
> Well ok, we could create alias names for all protocols.
> But often you don't know which protocols to conform to when you
> compile your module!
>
> What about:
>
>  -- module A --
>  class A {
>    func foo() {}
>  }
>
>  -- module B --
>  protocol Foo {
>    func foo()
>  }
>  extension A: Foo {}
>
> What is your ABI name for A.foo()?
>
> Let's keep it simple!
> If a simple warning about unrelated methods in a protocol conformance
> extension solves 95% of our problem,
> then we shouldn't overengineer and throw away all our flexibility just
> to be 100% explicit about which protocol uses which members.

-- 
-Dave


More information about the swift-evolution mailing list