<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 Jun 2, 2016, at 23:24, Thorsten Seitz &lt;<a href="mailto:tseitz42@icloud.com" class="">tseitz42@icloud.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><div class=""><br class=""></div><div class=""><br class="">Am 02. Juni 2016 um 05:15 schrieb Jordan Rose via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt;:<br class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="msg-quote" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" data-mce-style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jun 1, 2016, at 14:18, Austin Zheng &lt;<a href="mailto:austinzheng@gmail.com" class="" data-mce-href="mailto:austinzheng@gmail.com">austinzheng@gmail.com</a>&gt; wrote:</div><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">I'd also like to express my support for the proposal to delineate generic and existential syntax: all existentials must be written with Any&lt;...&gt;; generic type constraints cannot use it. I hope this will make it clear to people learning and using the language that, despite their superficial similarities, they are actually two different concepts.</div></div></div></blockquote><br class=""></div><div class="">This is&nbsp;<i class="">definitely</i>&nbsp;getting off-topic for this particular review, but I’ve come to agree with you. I can only speak for myself, but back when we were implementing protocols in Swift it felt great to eliminate the wedge between ’NSTableView *’ and ‘id &lt;NSTableViewDelegate&gt;’. But then we started using protocols for many more things in Swift, and it turns out that the simple use case of “I have a protocol-typed property” isn’t really the one worth optimizing for anymore. When they’re arguments, you <i class="">more often than not</i>&nbsp;might want to use them generically, and you should at least be <i class="">thinking</i>&nbsp;about that when you define a function.</div><div class=""><br class=""></div><div class="">Where we are today, the protocol-typed value is the obvious choice, and then you move to generics when the compiler tells you no. Having the choice be between these two:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class="" data-mce-style="margin: 0 0 0 40px; border: none; padding: 0px;"><div class="">func foo&lt;T: SignedInteger&gt;(value: T)</div><div class="">func foo(value: Any&lt;SignedInteger&gt;)</div></blockquote><div class=""><br class=""></div><div class="">makes it a little more likely that someone will stop and think about picking the first.</div></div></blockquote></div><div class=""><span class=""><br data-mce-bogus="1" class=""></span></div><div class=""><span class="">But doesn't this apply not only for protocols but for non-final classes, too? These are existentials as well, i.e. C ::= ∃ t : C . t<br data-mce-bogus="1" class=""></span></div><div class=""><span class=""><br data-mce-bogus="1" class=""></span></div><div class=""><span class="">As a result we would have to write all protocols and all non-final class types with `Any&lt;&gt;`:<br data-mce-bogus="1" class=""></span></div><div class=""><span class=""><br data-mce-bogus="1" class=""></span></div><div class=""><span class="">func foo(table: Any&lt;NSTableView&gt;)</span></div></div></div></div></blockquote><br class=""></div><div>That’s a good “slippery slope” argument, definitely worth bringing up. I think my counterpoint is that I’m not convinced that writing something generic over non-final classes is a common case. People use subclasses for dynamic polymorphism a lot more than they do static, i.e. the static type of a class doesn’t really give you any more information than the dynamic type. Additionally:</div><div><br class=""></div><div>- You have to see the allocation to do optimization anyway,</div><div>- The compiler can optimize equally well whether you use a generic function or plain old dynamic dispatch.</div><div>- A class reference is already as efficient to pass around as it can be, whereas existentials and generics are more expensive than their concrete types.</div><div><br class=""></div><div>But it’s definitely something to consider.</div><br class=""><div class="">Jordan</div></body></html>