<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=""><div class="">This would be wonderful - is it something that could happen in the Swift 3 timeframe? Is it something that myself or someone else could work on a formal proposal for?</div><div class=""><br class=""></div><div class="">-DW</div><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 3, 2016, at 4:17 PM, Douglas Gregor 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 dir="auto" class=""><div class=""><span class=""></span></div><div class=""><br class=""><div style="direction: ltr;" class=""><blockquote type="cite" class=""><div class="">On Jan 3, 2016, at 6:48 AM, Антон Жилин 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=""><div dir="ltr" class=""><div style="font-size:12.8px" class="">Introduction of interfaces will clean up the current blend of static and dynamic protocols, and solve at least three popular issues.</div><div style="font-size:12.8px" class="">Please see:</div><div style="font-size:12.8px" class=""><a href="https://github.com/Anton3/swift-evolution/blob/master/proposals/0000-introducing-interfaces.md" class="">https://github.com/Anton3/swift-evolution/blob/master/proposals/0000-introducing-interfaces.md</a></div></div></div></blockquote><div style="direction: ltr;" class=""><br class=""></div>I am *completely* against this proposal.</div><div style="direction: ltr;" class=""><br class=""></div><div style="direction: ltr;" class="">Fundamentally, you're trying to address the limitation that protocols with Self or associated type requirements can't be existential. But it's just a limitation that isn't (conceptually) that hard to fix: the primary operation you need to work with an existing of such a protocol is to "open" a value of existential type, giving a name to the dynamic type it stores. Let's invent one:</div><div style="direction: ltr;" class=""><br class=""></div><div style="direction: ltr;" class="">&nbsp; func eq(x: Equatable, y: Equatable) -&gt; Bool {</div><div style="direction: ltr;" class="">&nbsp; &nbsp; // give the name T to the dynamic type stored in xT</div><div style="direction: ltr;" class="">&nbsp; &nbsp; let xT = open x as T</div><div style="direction: ltr;" class="">&nbsp; &nbsp; // is y also storing a T?</div><div style="direction: ltr;" class="">&nbsp; &nbsp; guard let yT = y as? T else { return false }</div><div style="direction: ltr;" class="">&nbsp; &nbsp; // check whether the Ts are equal</div><div style="direction: ltr;" class="">&nbsp; &nbsp; return xT == yT</div><div style="direction: ltr;" class="">&nbsp; }</div><div style="direction: ltr;" class=""><br class=""></div><div style="direction: ltr;" class="">Ignore the syntax: semantically, we've gone from a "dynamic" existential thing back to something more "static", just by giving a name to the type. Swift generics aren't really even static in any sense: what the do is give names to the types of values so one can establish relationships among different values. "open..as" would do that for existentials.&nbsp;</div><div style="direction: ltr;" class=""><br class=""></div><div style="direction: ltr;" class="">Note that ether Swift compilers AST and SIL both have "open existential" operations that do this internally. They have no spelling in Swift code, but they are useful to describe operations on existentials. At present, they cannot be formed when the existential involves a protocol with Self or associated type requirements, but that's a limitation that isn't hard to address.&nbsp;</div><div style="direction: ltr;" class=""><br class=""></div><div style="direction: ltr;" class="">As for your concerns about knowing when one can dynamically override and when one cannot... &nbsp;There are issues here that need to be addressed. They aren't significant enough to warrant such a drastic change, and may not even require language changes at all.&nbsp;</div><div style="direction: ltr;" class=""><br class=""></div><div style="direction: ltr;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>- Doug</div><div style="direction: ltr;" class=""><br class=""></div><div style="direction: ltr;" class=""><br class=""></div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=nE9rxSXA5G4kxsTVkgv43vFcOQoCM-2FU-2BigXPSqPoICLQMF0Is2N1gVcYyd8LXauWU01V8ADskXgeA1dZAXS87kb5mrtSnua8ix3PvTqk8IjbkCFnioGdyq-2BKvhwvXwvyetVprM5QJNhgoafyPtUnsoK0Jd9PVrhUVERURHcV29O9ap7P5ZtW-2FOxTbxXomN8xjYwI10z8Hb2x7y5-2BqncZc5sWcNEbG-2B6FFuGHrYPzWeE-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
</div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>