[swift-evolution] [Completing Generics] Completing protocol extension diagnostics

Howard Lovatt howard.lovatt at gmail.com
Wed Mar 9 21:43:49 CST 2016


+1 to all of Goffredo's comments.

  -- Howard.

On 4 March 2016 at 18:41, Goffredo Marocchi via swift-evolution <
swift-evolution at swift.org> wrote:

> Brent, why is dynamic dispatching for protocol extension default
> implementations wrong in your mind? Wouldn't you agree that when static
> dispatching introduces such a side effect that it should not be
> automatically applied and perhaps a keyword should be added if you really
> wanted static dispatching nonetheless?
>
> I think that code execution should not be affected by type casting, it
> feels like a very confusing part of the language.
>
> Sent from my iPhone
>
> On 4 Mar 2016, at 07:06, Brent Royal-Gordon via swift-evolution <
> swift-evolution at swift.org> wrote:
>
> >> (B) and (C) could be mitigated by shadowing warnings, and we've also
> floated ideas for making them behave as intended, by implicitly forwarding
> protocol requirements into class methods to address (B) and/or introducing
> dynamic dispatch for protocol extensions to address (C).
> >
> > For what it's worth, I've posted threads several times aimed at
> addressing (C) through better warnings and keywording, and each time I've
> gotten lost of feedback from people who just want it dynamically
> dispatched. I wasn't aware of (B), but my guess is that I'd have heard the
> same thing if I'd brought it up.
> >
> >> - Adopting an explicit 'implements' modifier, in the spirit of
> 'override', to mark a declaration as being intended to fulfill a
> requirement. This adds boilerplate we'd like to avoid, and also interferes
> with retroactive modeling.
> >
> > One possible way around that second issue is to permit you to mark the
> conformance itself as `implements` when you're doing retroactive modeling.
> >
> >    protocol Arithmetic {
> >        func + (lhs: Self, rhs: Self) -> Self
> >        func - (lhs: Self, rhs: Self) -> Self
> >        func * (lhs: Self, rhs: Self) -> Self
> >        func / (lhs: Self, rhs: Self) -> Self
> >    }
> >
> >    extension Int: implements Arithmetic {}
> >    extension Double: implements Arithmetic {}
> >
> > If we just turned off the keyword requirement when the conformance was
> marked, people would abuse the feature, so perhaps it merely indicates that
> one or more members defined *outside* the current module implement the
> requirements. Any members *inside* the current module would still have to
> be individually marked. (And if the protocol wasn't at least partially
> implemented by external members, the `implements` in the conformance would
> be illegal.)
> >
> > --
> > Brent Royal-Gordon
> > Architechies
> >
> > _______________________________________________
> > swift-evolution mailing list
> > swift-evolution at swift.org
> > https://lists.swift.org/mailman/listinfo/swift-evolution
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160310/55d69f5a/attachment-0001.html>


More information about the swift-evolution mailing list