<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 12 Jan 2016, at 10:45, Howard Lovatt via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="margin: 0px; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">Currently you generics are invariant whereas function arguments etc. are covariant. I am suggesting that if the way generics are implemented is changed then they can be made covariant and that this will add considerable utility to Swift generics.</span></font></div></div></div></blockquote><div><br class=""></div><div>What about contravariant scenarios? Examples from C#:</div><div><br class=""></div><div>IEnumerable<out T> // covariant</div><div>since if S : T then we want IEnumerable<S> : IEnumerable<T></div><div><br class=""></div><div>because IEnumerable<T> only returns T’s.</div><div><br class=""></div><div>but then</div><div><br class=""></div><div>IComparable<in T> // contravariant</div><div>since if S : T we definitely want IComparable<T> : IComparable<S></div><div><br class=""></div><div>because IComparable<T> only takes T’s as input.</div><div><br class=""></div><div>reversing either of the above would make the type system unsound.</div><div>Any variance be default can’t be sound, and I am strongly opposed to that.</div><div><br class=""></div><div>-Sune</div><div><br class=""></div></div></body></html>