[swift-evolution] Proposal: Universal dynamic dispatch for method calls
Gwendal Roué
gwendal.roue at gmail.com
Wed Dec 9 04:30:07 CST 2015
> Le 9 déc. 2015 à 11:22, T.J. Usiyan <griotspeak at gmail.com> a écrit :
>
> I actually suggest something along the lines of
>
> protocol Foo {
> final func doIt() -> String
> }
>
> extension Foo {
> final func doIt() -> String {
> print("I did it.")
> }
> final func doThat() {
> print("I did that.")
> }
> }
>
> to indicate that foo will be provided in this module and is not ever to be dynamically dispatched. This draws attention to the fact that dispatch is static in a clear consistent manner.
>
> TJ
In this particular example, do you mean that a class that implements Foo would have to declare its own doIt() as final, and can not implement its own doThat() ?
class C : Foo {
final func doIt() -> String { … } // final required
final func doThat() { … } // illegal
}
Gwendal
More information about the swift-evolution
mailing list