<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">Hi Kevin,</div><div class="gmail_quote"><br></div><div class="gmail_quote">Thank you for your feedback!</div><div class="gmail_quote"><br></div><div class="gmail_quote">On Fri, Dec 18, 2015 at 3:13 PM, Kevin Ballard via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
<div>2. One of the added constraints looks like<br></div>
<div> </div>
<pre>S<span style="color:rgb(167,29,93)">.</span>SubSequence<span style="color:rgb(167,29,93)">.</span>SubSequence <span style="color:rgb(167,29,93)">==</span> S<span style="color:rgb(167,29,93)">.</span>SubSequence<br></pre><div> </div>
<div>with a comment saying that ideally the set of constraints would apply to the SequenceType protocol but that&#39;s not currently possible. This makes sense for the other constraints (that SubSequence conforms to SequenceType and has the same element), but this particular constraint, that the subsequence type must have itself as its own subsequence, surprises me a little. I can see why it&#39;s needed here (because that&#39;s the only way you can guarantee that recursing through SubSequences always finds SequenceTypes with the right element), but ideally we wouldn&#39;t actually require it to be the _same_ sequence, just that it is some sequence with the same element type. If we ever change Swift such that these constraints can be expressed on the SequenceType definition itself, then presumably we&#39;ll be able to drop this == constraint entirely as the SequenceType protocol itself will ensure that its subsequence is a sequence of the same element type (which will satisfy the need to have it be true after arbitrary levels of recursion).</div></div></blockquote><div><br></div><div>The idea behind putting this constraint into the protocol was to make it possible to write code that repeatedly slices a collection without getting a ton of different types along the way:</div><div><br></div><div>var myCollectionSlice = myCollection[myCollection.indices]</div><div>myCollectionSlice = myCollectionSlice.dropFirst()</div><div><br></div><div>Also, we couldn&#39;t come up with an example of a sequence or a collection that needs to have different SubSequence types on different depth levels for efficiency or type safety reasons.  Given that we think we aren&#39;t limiting expressivity with this constraint, having a simpler model (the operation of slicing slices is closed in the set of types) is better.</div><div><br></div><div>I&#39;d be happy to hear if you know some sequence or collection types that would benefit from not having this constraint.</div><div><br></div><div>Dmitri</div><div><br></div></div>-- <br><div class="gmail_signature">main(i,j){for(i=2;;i++){for(j=2;j&lt;i;j++){if(!(i%j)){j=0;break;}}if<br>(j){printf(&quot;%d\n&quot;,i);}}} /*Dmitri Gribenko &lt;<a href="mailto:gribozavr@gmail.com" target="_blank">gribozavr@gmail.com</a>&gt;*/</div>
</div></div>