<div dir="ltr">(inline)<br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 26, 2016 at 12:22 PM, David Hart <span dir="ltr">&lt;<a href="mailto:david@hartbit.com" target="_blank">david@hartbit.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi Austin,<div><br></div><div>I never had te occasion to say thanks for the work you have put in this proposal, so thanks! I’m really looking forward to be able to have some form of it accepted and implemented in Swift.</div></div></blockquote><div><br></div><div>Thank you! I just hope a proposal like this one ends up being good enough that it means less work for the core team, not more...</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><br></div><div>Here are a few comments:</div><div><br></div><div>1) Why would <span style="color:rgb(51,51,51);font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;background-color:rgba(0,0,0,0.0392157)">Any&lt;&gt;</span> and <span style="color:rgb(51,51,51);font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;background-color:rgba(0,0,0,0.0392157)">Any&lt;NSView&gt;</span> be illegal? What error messages would they generate? Why not make them simply synonymous to <span style="color:rgb(51,51,51);font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;background-color:rgba(0,0,0,0.0392157)">Any</span>, and <span style="color:rgb(51,51,51);font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;background-color:rgba(0,0,0,0.0392157)">NSView</span>, the same way <span style="color:rgb(51,51,51);font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;background-color:rgba(0,0,0,0.0392157)">protocol&lt;&gt;</span> currently behaves?</div></div></blockquote><div><br></div><div>&quot;Any&lt;&gt;&quot; being illegal is a syntactic battle that is being fought over in a different thread; I&#39;m not personally invested one way or another. (We might not even adopt &quot;Any&quot; syntax specifically; Joe Groff has ideas for a different syntax that doesn&#39;t use the brackets.)</div><div><br></div><div>&quot;Any&lt;NSView&gt;&quot; is an existential, and &quot;NSView&quot; isn&#39;t. Existentials&#39; metatypes are different from the metatypes of concrete types, and the ways they can be used with generics is different as well. My opinion is that Any&lt;...&gt; signifies an existential, and allowing the use of &quot;Any&lt;SomeClass&gt;&quot; as a concrete type would just confuse people even more.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><br></div><div>2) You say that &quot;An <span style="color:rgb(51,51,51);font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;background-color:rgba(0,0,0,0.0392157)">Any&lt;...&gt;</span> existential can have zero or one where clauses, <b>following the list of requirements.</b>” This seems to be contradicted in two places: </div></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><br></div><div>In the example under <b>Nested <span style="color:rgb(51,51,51);font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;background-color:rgba(0,0,0,0.0392157)">Any&lt;...&gt;</span></b>, which should probably be edited to:</div><div><br></div><div><pre style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal;color:rgb(51,51,51)"><span style="color:rgb(150,152,150)">// NOT ALLOWED</span>
<span style="color:rgb(150,152,150)">// This is impossible to fufill. A collection&#39;s elements cannot be both strings</span>
<span style="color:rgb(150,152,150)">// and integers at the same time.</span>
<span style="color:rgb(167,29,93)">let</span> a <span style="color:rgb(167,29,93)">:</span> <span style="color:rgb(0,134,179)">Any</span><span style="color:rgb(167,29,93)">&lt;</span>Collection, <span style="color:rgb(0,134,179)">Any</span><span style="color:rgb(167,29,93)">&lt;</span>Collection <span style="color:rgb(167,29,93)">where</span> Collection<span style="color:rgb(167,29,93)">.</span>Element <span style="color:rgb(167,29,93)">==</span> <span style="color:rgb(0,134,179)">Int</span><span style="color:rgb(167,29,93)">&gt; </span><span style="color:rgb(167,29,93)">where</span> Collection<span style="color:rgb(167,29,93)">.</span>Element <span style="color:rgb(167,29,93)">==</span> <span style="color:rgb(0,134,179)">String</span><span style="color:rgb(167,29,93)">&gt;</span></pre><div><br></div></div></div></blockquote><div><br></div><div>Yes, my wording should have been clearer. What I meant is that you can&#39;t have more than one where clause in the *current* Any&lt;&gt;, but you can nest another Any&lt;&gt; that has its own where clause. I&#39;ll edit the copy.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div></div></div><div>In the <b><span style="color:rgb(51,51,51);font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;background-color:rgba(0,0,0,0.0392157)">where</span> clause</b> section, you say:</div><div><br></div><div><span style="color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">Associated types used within the </span><code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(51,51,51)">where</code><span style="color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"> clause must belong to the protocols in the current or previous requirements.</span></div><div><br></div><div>This sounds a bit bizarre because where clauses always appear at the end, so there is no such “current” requirements and all requirements are “previous”.</div></div></blockquote><div><br></div><div>You are right; I&#39;ll fix that. The weird verbiage is a remnant of an earlier draft where each protocol could have its own where clause.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><br></div><div>I still have to take the time to finish digesting the end of the proposal.</div></div></blockquote><div><br></div><div>Happy to clarify or answer any questions you might have.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><span class="HOEnZb"><font color="#888888"><div><br></div><div>David.</div></font></span><div><br><div><blockquote type="cite"><span class=""><div>On 26 May 2016, at 07:53, Austin Zheng via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br></span><div><div dir="ltr"><span class="">The inimitable Joe Groff provided me with an outline as to how the design could be improved. I&#39;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&#39; 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 &#39;anonymous&#39; 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&#39;s value&#39;s underlying type&#39;s associated type.</div><div><br></div></span><div><div class="h5"><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 &#39;as&#39; can be used to turn values of these anonymous associated types back into existentials based on the constraints defined earlier. &#39;as?&#39; 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: <a href="https://github.com/austinzheng/swift-evolution/blob/az-existentials/proposals/XXXX-enhanced-existentials.md" target="_blank">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></div><div><div class="h5"><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><br>
On May 23, 2016, at 9:52 PM, Brent Royal-Gordon via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br>
<br>
&gt;&gt; One initial bit of feedback -  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;  associatedtype Element<br>
&gt;&gt;  associatedtype Iterator: any&lt;IteratorProtocol where IteratorProtocol.Element==Element&gt;<br>
&gt;&gt;  associatedtype SubSequence: any&lt;Sequence where Sequence.Element == Element&gt;<br>
&gt;&gt;  …<br>
&gt;&gt; }<br>
&gt;<br>
&gt; That&#39;s not really the same thing. Any&lt;IteratorProtocol&gt; is an existential, not a protocol. It&#39;s basically an automatically-generated version of our current `AnyIterator&lt;T&gt;` type (though with some additional flexibility). It can&#39;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.  You can do this with the protocol composition operator today and the future existential is just an extension of that capability.<br>
<span><br>
&gt;<br>
&gt; What *would* work is allowing `where` clauses on associated types:<br>
&gt;<br>
&gt;&gt; protocol Sequence {<br>
&gt;&gt;  associatedtype Element<br>
&gt;&gt;  associatedtype Iterator: IteratorProtocol where Iterator.Element==Element<br>
&gt;&gt;  associatedtype SubSequence: Sequence where SubSequence.Element == Element<br>
&gt;&gt;  …<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><div>&gt; _______________________________________________<br>
&gt; swift-evolution mailing list<br>
&gt; <a href="mailto:swift-evolution@swift.org" target="_blank">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" target="_blank">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>
_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">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></div></div></div></blockquote></div><br></div></div></blockquote></div><br></div></div>