[swift-evolution] Mark protocol methods with their protocol

Xiaodi Wu xiaodi.wu at gmail.com
Tue Sep 20 10:14:12 CDT 2016


I think that's a simple and elegant solution. The private member exception
can be extended so that any member with less visibility than the minimum of
the type and protocol visibility would be allowed.
On Tue, Sep 20, 2016 at 09:48 Martin Waitz <tali at admingilde.org> wrote:

> Hello everybody,
>
> Several suggestions are floating around about explicitly marking a
> method to implement a protocol requirement.
>
> E.g.:
>
> > class Foo : Bar {
> >       implement func foo() {...}
> > }
>
> However, with extensions we can already do something very similar:
>
>    class Foo {
>        ....
>    }
>    extension Foo: Bar {
>        func foo() {...}
>    }
>
> Maybe simply adding a new warning would already help.
> Extensions which introduce new protocol conformances could be reserved
> for those methods which are already defined within the protocol.
> Whenever such an extension contains an unrecognized method, we could
> issue a warning.
> Or maybe even an error, but we should allow private methods as an
> exception (for helper functions which are clearly not related to the
> protocol).
>
> This way, when the programmer wants to make sure that her new method is
> used by a protocol then she can simply put that method in an extension.
>
> --
> Martin
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160920/16792afb/attachment.html>


More information about the swift-evolution mailing list