I think it would be a good idea to remove the covariance of Array since it is compiler magic and that would clear the way for a more general solution. <br><br>On Friday, 26 February 2016, Radek Pietruszewski via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Interesting. Two Qs:<br>
<br>
- when you say &quot;moving in the direction of encouraging the use of abstract AnyCollection values&quot;, do you mean in general? To encourage people to use AnyCollection&lt;T&gt; instead of [T] in their code?<br>
- how could covariant collection casting look like in this world?<br>
<br>
Sent from my iPhone<br>
<br>
&gt; On 25 Feb 2016, at 20:12, Joe Groff &lt;<a href="javascript:;" onclick="_e(event, &#39;cvml&#39;, &#39;jgroff@apple.com&#39;)">jgroff@apple.com</a>&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt;&gt; On Feb 25, 2016, at 9:07 AM, Jordan Rose via swift-evolution &lt;<a href="javascript:;" onclick="_e(event, &#39;cvml&#39;, &#39;swift-evolution@swift.org&#39;)">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; I think there are two things going on here:<br>
&gt;&gt;<br>
&gt;&gt; - The compiler allows a memory-corrupting cast, which should be rejected (a bug).<br>
&gt;&gt; - But it&#39;s a useful thing to do (a language change).<br>
&gt;&gt;<br>
&gt;&gt; I&#39;m actually surprised about the bug, since we get plenty of questions about why the compiler doesn&#39;t allow it, implying that the compiler is indeed rejecting it. The answer is that protocol values and class values don&#39;t have the same representation, so converting between [Eatable] and [Burger] is an O(N) operation that requires allocating a new array. But that may not be a good enough reason not to allow it—conversions from NSArray to Array can do the same thing if the NSArray was mutable.<br>
&gt;<br>
&gt; I&#39;ve overheard discussion of removing the covariant container conversions altogether, since they&#39;re inconsistent with the rest of the language, lead to a lot of type-checker and runtime dynamic cast complexity, and have unpredictable performance if generalized, and moving in the direction of encouraging the use of abstract AnyCollection values instead of concrete Arrays, that would free us to make covariant conversions cheaper by wrapping instead of eagerly mapping the array representation.<br>
&gt;<br>
&gt; -Joe<br>
&gt;<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="javascript:;" onclick="_e(event, &#39;cvml&#39;, &#39;swift-evolution@swift.org&#39;)">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote><br><br>-- <br>-- Howard.<br>