<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 &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; 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&nbsp;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&lt;out T&gt; // covariant</div><div>since if S : T then we want IEnumerable&lt;S&gt; : IEnumerable&lt;T&gt;</div><div><br class=""></div><div>because IEnumerable&lt;T&gt; only returns T’s.</div><div><br class=""></div><div>but then</div><div><br class=""></div><div>IComparable&lt;in T&gt; // contravariant</div><div>since if S : T we definitely want IComparable&lt;T&gt; : IComparable&lt;S&gt;</div><div><br class=""></div><div>because IComparable&lt;T&gt; 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>