<div dir="ltr">But then any time as user of the pipeline I&#39;m writing would like a new type of collection they will be forced to inherit this new protocol vs one they&#39;re already familiar with and which the collection may already conform too.</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 2, 2017 at 1:53 PM, Matthew Johnson <span dir="ltr">&lt;<a href="mailto:matthew@anandabits.com" target="_blank">matthew@anandabits.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span class=""><blockquote type="cite"><div>On Feb 2, 2017, at 3:46 PM, Rex Fenley &lt;<a href="mailto:rex@remind101.com" target="_blank">rex@remind101.com</a>&gt; wrote:</div><br class="m_-7576891152844605977Apple-interchange-newline"><div><div dir="ltr">My use case is RLMArray and it can&#39;t implement <span style="font-size:12.8px">RangeReplaceableColl<wbr>ection</span> though because `init` is unavailable, additionally, there&#39;s a lot of parts to the protocol that would take some time to implement correctly if I could. They offer a Swift type List that wraps RLMArray and does a bunch of stuff to implement <span style="font-size:12.8px">RangeReplaceableColl<wbr>ection,</span> but they discourage using their Swift library in mixed Obj-C/Swift projects and certain model objects simply couldn&#39;t use the List type anyway because they&#39;re also used in Obj-C and List is not @objc compliant.<br><br>So this leaves me in situations where when I need to use Array or RLMArray I have to duplicate my code, not just in one place, but all the way down a pipeline in order to have my generics work with either <span style="font-size:12.8px">RangeReplaceableCollect<wbr>ion or </span>RLMArray.<br><br>If I could abstract the commonalities required by my application, I could just have a RLMArrayProtocol that has RLMArray&#39;s exposed function signatures and a new protocol Appendable = <span style="font-size:12.8px">RangeReplaceableCollection | </span>RLMArrayProtocol and this will type check all the way through the pipeline.<div><br></div><div>tl;dr - if a function signature required by a protocol is marked unavailable on a class, then disjunction is necessary in order to bridge the two (or more) types without duplicating code.</div></div></div></blockquote><div><br></div></span><div>You should be able to solve this problem today by creating a custom protocol that you use as a constraint in your generic code and providing conformances for both Array and RLMArray.</div><div><div class="h5"><br><blockquote type="cite"><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 2, 2017 at 1:35 PM, Matthew Johnson <span dir="ltr">&lt;<a href="mailto:matthew@anandabits.com" target="_blank">matthew@anandabits.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><span><blockquote type="cite"><div><br>On Feb 2, 2017, at 3:26 PM, Rex Fenley via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_-7576891152844605977m_4684597058227267120Apple-interchange-newline"><div><div dir="ltr">Hello, I believe there was some discussion about this quite awhile ago. I was wondering if there&#39;s any interest in including a protocol &#39;or&#39; 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&#39;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.</div></div></blockquote><div><br></div></span><div>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:</div><div><br></div><div>extension SpecializedDatabaseCollection: RangeReplaceableCollection {</div><div>   // if necessary, provide forwarding wrappers where the member names don’t match up.</div><div>}</div><div><br></div><div>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.</div><div><br></div><div>Is there something you’re hoping to do that you can’t solve by simply extending the framework types?</div><span><br><blockquote type="cite"><div><div dir="ltr"><div><br></div><div>Simplified example:</div><div><br></div><div>protocol Animal {</div><div>    var hasEars: Bool { get }</div><div>    func grow()</div><div>}</div><div><br></div><div><div>protocol Plant {</div><div>    var isGreen: Bool { get }</div><div>    func grow()</div><div>}</div><div><br></div><div>protocol LivingThing = Plant | Animal // or a different syntax</div><div><br></div><div>LivingThing&#39;s is as follows</div><div>{</div><div>    func grow()</div><div>}</div></div></div></div></blockquote></span><blockquote type="cite"><div><span><div dir="ltr"><div><div><br></div>-- <br><div class="m_-7576891152844605977m_4684597058227267120gmail_signature"><div dir="ltr"><span><div style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="font-size:16px;font-family:arial;background-color:transparent;font-style:italic;vertical-align:baseline;white-space:pre-wrap">Rex Fenley</span><span style="font-size:16px;font-family:arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">  </span><span style="font-size:11px;font-family:arial;color:rgb(153,153,153);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">|</span><span style="line-height:1.15;font-family:arial;color:rgb(153,153,153);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">  </span><span style="font-size:11px;font-family:arial;color:rgb(153,153,153);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">IOS DEVELOPER</span><br></div></span><span><br><div style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11px;font-family:arial;color:rgb(153,153,153);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><img src="https://lh5.googleusercontent.com/xMgzw3JkFL3DLkdwyq0WxJzKs_XP57gVVCaBMvgi1FKCjSeue0xdx3JZeCWBlxN4KRHhHOfdvJbc1N-AjTwXcKIq4cjJg9H7iaFpQ8WbO4N3c9Y5dzi19cPOs_owPquuqw" width="250px;" height="53px;" style="border:none"></span></div><div style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><a href="https://www.remind.com/" style="text-decoration:none" target="_blank"><span style="font-size:11px;font-family:arial;color:rgb(17,85,204);font-weight:bold;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">Remind.com</span></a><span style="font-family:arial;vertical-align:baseline;white-space:pre-wrap;background-color:transparent"> </span><span style="font-size:11px;font-family:arial;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">|  </span><a href="http://blog.remind.com/" style="text-decoration:none" target="_blank"><span style="font-size:11px;font-family:arial;color:rgb(17,85,204);text-decoration:underline;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">BLOG</span></a><span style="font-size:11px;font-family:arial;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">  |  </span><a href="https://twitter.com/remindhq" style="text-decoration:none" target="_blank"><span style="font-size:11px;font-family:arial;color:rgb(17,85,204);text-decoration:underline;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">FOLLOW US</span></a><span style="font-size:11px;font-family:arial;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">  | </span><span style="font-family:arial;vertical-align:baseline;white-space:pre-wrap;background-color:transparent"> </span><span style="text-decoration:underline;font-size:11px;font-family:arial;color:rgb(17,85,204);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><a href="https://www.facebook.com/remindhq" style="text-decoration:none" target="_blank">LIKE US</a></span></div></span></div></div>
</div></div></span><span>
______________________________<wbr>_________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-evolution</a><br></span></div></blockquote></div><br></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="m_-7576891152844605977gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><span><div style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="font-size:16px;font-family:Arial;background-color:transparent;font-style:italic;vertical-align:baseline;white-space:pre-wrap">Rex Fenley</span><span style="font-size:16px;font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">  </span><span style="font-size:11px;font-family:Arial;color:rgb(153,153,153);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">|</span><span style="line-height:1.15;font-family:Arial;color:rgb(153,153,153);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">  </span><span style="font-size:11px;font-family:Arial;color:rgb(153,153,153);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">IOS DEVELOPER</span><br></div></span><span><br><div style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11px;font-family:Arial;color:rgb(153,153,153);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><img src="https://lh5.googleusercontent.com/xMgzw3JkFL3DLkdwyq0WxJzKs_XP57gVVCaBMvgi1FKCjSeue0xdx3JZeCWBlxN4KRHhHOfdvJbc1N-AjTwXcKIq4cjJg9H7iaFpQ8WbO4N3c9Y5dzi19cPOs_owPquuqw" width="250px;" height="53px;" style="border:none"></span></div><div style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><a href="https://www.remind.com/" style="text-decoration:none" target="_blank"><span style="font-size:11px;font-family:Arial;color:rgb(17,85,204);font-weight:bold;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">Remind.com</span></a><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap;background-color:transparent"> </span><span style="font-size:11px;font-family:Arial;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">|  </span><a href="http://blog.remind.com/" style="text-decoration:none" target="_blank"><span style="font-size:11px;font-family:Arial;color:rgb(17,85,204);text-decoration:underline;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">BLOG</span></a><span style="font-size:11px;font-family:Arial;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">  |  </span><a href="https://twitter.com/remindhq" style="text-decoration:none" target="_blank"><span style="font-size:11px;font-family:Arial;color:rgb(17,85,204);text-decoration:underline;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">FOLLOW US</span></a><span style="font-size:11px;font-family:Arial;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">  | </span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap;background-color:transparent"> </span><span style="text-decoration:underline;font-size:11px;font-family:Arial;color:rgb(17,85,204);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><a href="https://www.facebook.com/remindhq" style="text-decoration:none" target="_blank">LIKE US</a></span></div></span></div></div>
</div>
</div></blockquote></div></div></div><br></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><span><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="font-size:16px;font-family:Arial;background-color:transparent;font-style:italic;vertical-align:baseline;white-space:pre-wrap">Rex Fenley</span><span style="font-size:16px;font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">  </span><span style="font-size:11px;font-family:Arial;color:rgb(153,153,153);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">|</span><span style="line-height:1.15;font-family:Arial;color:rgb(153,153,153);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">  </span><span style="font-size:11px;font-family:Arial;color:rgb(153,153,153);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">IOS DEVELOPER</span><br></p></span><span><br><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11px;font-family:Arial;color:rgb(153,153,153);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><img src="https://lh5.googleusercontent.com/xMgzw3JkFL3DLkdwyq0WxJzKs_XP57gVVCaBMvgi1FKCjSeue0xdx3JZeCWBlxN4KRHhHOfdvJbc1N-AjTwXcKIq4cjJg9H7iaFpQ8WbO4N3c9Y5dzi19cPOs_owPquuqw" width="250px;" height="53px;" style="border:none"></span></p><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><a href="https://www.remind.com/" style="text-decoration:none" target="_blank"><span style="font-size:11px;font-family:Arial;color:rgb(17,85,204);font-weight:bold;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">Remind.com</span></a><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap;background-color:transparent"> </span><span style="font-size:11px;font-family:Arial;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">|  </span><a href="http://blog.remind.com/" style="text-decoration:none" target="_blank"><span style="font-size:11px;font-family:Arial;color:rgb(17,85,204);text-decoration:underline;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">BLOG</span></a><span style="font-size:11px;font-family:Arial;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">  |  </span><a href="https://twitter.com/remindhq" style="text-decoration:none" target="_blank"><span style="font-size:11px;font-family:Arial;color:rgb(17,85,204);text-decoration:underline;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">FOLLOW US</span></a><span style="font-size:11px;font-family:Arial;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">  | </span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap;background-color:transparent"> </span><span style="text-decoration:underline;font-size:11px;font-family:Arial;color:rgb(17,85,204);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><a href="https://www.facebook.com/remindhq" style="text-decoration:none" target="_blank">LIKE US</a></span></p></span></div></div>
</div>