<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Great news :)<br><br>Sent from my iPhone</div><div><br>On 26 May 2016, at 06:53, Austin Zheng via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">The inimitable Joe Groff provided me with an outline as to how the design could be improved. I've taken the liberty of rewriting parts of the proposal to account for his advice.<div><br></div><div>It turns out the runtime type system is considerably more powerful than I expected. The previous concept in which protocols with associated types' APIs were vended out selectively and using existentials has been discarded.</div><div><br></div><div>Instead, all the associated types that belong to an existential are accessible as 'anonymous' types within the scope of the existential. These anonymous types are not existentials - they are an anonymous representation of whatever concrete type is satisfying the existential's value's underlying type's associated type.</div><div><br></div><div>This is an enormous step up in power - for example, an existential can return a value of one of these anonymous associated types from one function and pass it into another function that takes the same type, maintaining perfect type safety but without ever revealing the actual type. There is no need anymore to limit the APIs exposed to the user, although there may still exist APIs that are semantically useless without additional type information.</div><div><br></div><div>A set of conversions has also been defined. At compile-time 'as' can be used to turn values of these anonymous associated types back into existentials based on the constraints defined earlier. 'as?' can also be used for conditional casting of these anonymously-typed values into potential actual types.</div><div><br></div><div>As always, the link is here, and feedback would be greatly appreciated:&nbsp;<a href="https://github.com/austinzheng/swift-evolution/blob/az-existentials/proposals/XXXX-enhanced-existentials.md">https://github.com/austinzheng/swift-evolution/blob/az-existentials/proposals/XXXX-enhanced-existentials.md</a></div><div><br></div><div>Best,</div><div>Austin</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 24, 2016 at 5:09 AM, Matthew Johnson via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
Sent from my iPad<br>
<span class=""><br>
On May 23, 2016, at 9:52 PM, Brent Royal-Gordon via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
<br>
&gt;&gt; One initial bit of feedback -&nbsp; I believe if you have existential types, I believe you can define Sequence Element directly, rather than with a type alias. e.g.<br>
&gt;&gt;<br>
&gt;&gt; protocol Sequence {<br>
&gt;&gt;&nbsp; associatedtype Element<br>
&gt;&gt;&nbsp; associatedtype Iterator: any&lt;IteratorProtocol where IteratorProtocol.Element==Element&gt;<br>
&gt;&gt;&nbsp; associatedtype SubSequence: any&lt;Sequence where Sequence.Element == Element&gt;<br>
&gt;&gt;&nbsp; …<br>
&gt;&gt; }<br>
&gt;<br>
&gt; That's not really the same thing. Any&lt;IteratorProtocol&gt; is an existential, not a protocol. It's basically an automatically-generated version of our current `AnyIterator&lt;T&gt;` type (though with some additional flexibility). It can't appear on the right side of a `:`, any more than AnyIterator could.<br>
<br>
</span>After this proposal you should be able to use these existentials anywhere you can place a constraint, so it would work.&nbsp; You can do this with the protocol composition operator today and the future existential is just an extension of that capability.<br>
<span class="im HOEnZb"><br>
&gt;<br>
&gt; What *would* work is allowing `where` clauses on associated types:<br>
&gt;<br>
&gt;&gt; protocol Sequence {<br>
&gt;&gt;&nbsp; associatedtype Element<br>
&gt;&gt;&nbsp; associatedtype Iterator: IteratorProtocol where Iterator.Element==Element<br>
&gt;&gt;&nbsp; associatedtype SubSequence: Sequence where SubSequence.Element == Element<br>
&gt;&gt;&nbsp; …<br>
&gt;&gt; }<br>
&gt;<br>
&gt; I believe this is part of the generics manifesto.<br>
&gt;<br>
&gt; --<br>
&gt; Brent Royal-Gordon<br>
&gt; Architechies<br>
&gt;<br>
</span><div class="HOEnZb"><div class="h5">&gt; _______________________________________________<br>
&gt; swift-evolution mailing list<br>
&gt; <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</div></div></blockquote></div><br></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>