[swift-evolution] Abstract methods

Mike Kluev mike.kluev at gmail.com
Mon Nov 6 09:19:21 CST 2017


on Sun, 5 Nov 2017 09:27:09 +0000 Goffredo Marocchi <panajev at gmail.com>
wrote:

>
> I would say that you kind of already entered a slippery slope when the
> extension to a protocol can add code / not just declare a behavioural
> contract ...


to me protocol extensions are both cool and evil. cool as you can add code.
evil because it's more natural to add another declarations in those
extensions rather than implementation:

protocol Foo {
    func foo()
}

extension Foo {
   func bar()    //*** natural assumption is that i can do this. but i can't
}

i'd say, abusing "extension protocol" syntax to add code looks like a
(cool) hack and my +1 would be for some other more explicit syntactic
construct for the purposes of adding code, for example:

implementation Foo {
    func foo() {
        ...
    }
}

Mike
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171106/413290be/attachment.html>


More information about the swift-evolution mailing list