>
> On Feb 2, 2017, at 3:26 PM, Rex Fenley via swift-evolution
> <[email protected]> wrote:
>
> Hello, I believe there was some discussion about this quite awhile ago. I was
> wondering if there's any interest in including a protocol 'or' type that
> would be the intersection of two protocols. This could be really useful in
> situations where a framework that the user has no control over implements a
> portion of some often used protocol. Such as specialized collections from an
> Database framework that don't implement RangeReplaceableCollection but have a
> set of methods that are equivalent. The user can then implement a protocol
> that is the intersection of those set of methods and not duplicate code.
If the specialized collection in the database framework already provides
functionality equivalent to `RangeReplaceableCollection` what you really want
to do is just provide the conformance you’re looking for in an extension:
extension SpecializedDatabaseCollection: RangeReplaceableCollection {
// if necessary, provide forwarding wrappers where the member names don’t
match up.
}
But in a case like this the framework itself really should provide this
conformance out of the box. If they didn’t, maybe there is a good reason so
you would want to find out why it wasn’t provided.
Is there something you’re hoping to do that you can’t solve by simply extending
the framework types?
>
> Simplified example:
>
> protocol Animal {
> var hasEars: Bool { get }
> func grow()
> }
>
> protocol Plant {
> var isGreen: Bool { get }
> func grow()
> }
>
> protocol LivingThing = Plant | Animal // or a different syntax
>
> LivingThing's is as follows
> {
> func grow()
> }
>
> --
> Rex Fenley | IOS DEVELOPER
>
>
> Remind.com <https://www.remind.com/> | BLOG <http://blog.remind.com/> |
> FOLLOW US <https://twitter.com/remindhq> | LIKE US
> <https://www.facebook.com/remindhq>_______________________________________________
> swift-evolution mailing list
> [email protected]
> https://lists.swift.org/mailman/listinfo/swift-evolution
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution