<div dir="ltr">I&#39;m still working on this. When you mention where clauses on associated types, how should I handle that in the context of the proposal?<div><br></div><div>* Consider where clauses part of the proposal (so that the proposal becomes &quot;recursive associated type constraints + where clauses on associated types&quot;)</div><div>* Assume that where clauses will definitely be accepted, and write the stdlib changes assuming that</div><div>* Assume that where clauses might not be accepted, and write the stdlib changes assuming that, but also have a section containing further stdlib changes conditional on where clauses being accepted</div><div><br></div><div>Best,</div><div>Austin</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Nov 13, 2016 at 7:55 PM, Douglas Gregor <span dir="ltr">&lt;<a href="mailto:dgregor@apple.com" target="_blank">dgregor@apple.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 dir="auto"><div><br><br>Sent from my iPhone</div><span class=""><div><br>On Nov 13, 2016, at 4:03 PM, Austin Zheng &lt;<a href="mailto:austinzheng@gmail.com" target="_blank">austinzheng@gmail.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">I&#39;d be happy to put something together, unless someone else wants to take it on.</div></div></blockquote><div><br></div></span>Great, thanks!<div><span class=""><br><blockquote type="cite"><div><div dir="ltr"><div><br></div><div>Doug, I also owe you a PR adding a minor amendment to one of the accepted proposals. I&#39;ll get to that this week.</div></div></div></blockquote><div><br></div></span>Sounds great. </div><div><br></div><div>  - Doug</div><span class=""><div><br><blockquote type="cite"><div><div dir="ltr"><div><div>Austin</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Nov 13, 2016 at 10:13 PM, Douglas Gregor 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"><div dir="auto"><div>Recursive protocol constraints is one small-looking feature that could greatly improve the standard library. The generics manifesto describes it this way:</div><div><br></div><div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px"><span style="background-color:rgba(255,255,255,0)">&quot;Currently, an associated type cannot be required to conform to its enclosing protocol (or any protocol that inherits that protocol). For example, in the standard library <code style="box-sizing:border-box;padding:0.2em 0px;margin:0px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">SubSequence</code> type of a <code style="box-sizing:border-box;padding:0.2em 0px;margin:0px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Sequence</code> should itself be a <code style="box-sizing:border-box;padding:0.2em 0px;margin:0px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Sequence</code>:</span></p><div class="m_8762435891985121735m_2981084392784924051highlight m_8762435891985121735m_2981084392784924051highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px"><pre style="box-sizing:border-box;word-wrap:normal;margin-top:0px;margin-bottom:0px;padding:16px;overflow:auto;line-height:1.45;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal"><font face="UICTFontTextStyleBody"><span style="white-space:normal;background-color:rgba(255,255,255,0)"><span class="m_8762435891985121735m_2981084392784924051pl-k" style="box-sizing:border-box">protocol</span> <span class="m_8762435891985121735m_2981084392784924051pl-en" style="box-sizing:border-box">Sequence</span> {
  <span class="m_8762435891985121735m_2981084392784924051pl-k" style="box-sizing:border-box">associatedtype</span> <span class="m_8762435891985121735m_2981084392784924051pl-v" style="box-sizing:border-box">Iterator</span> : <span class="m_8762435891985121735m_2981084392784924051pl-e" style="box-sizing:border-box"><span class="m_8762435891985121735m_2981084392784924051pl-c1" style="box-sizing:border-box">IteratorProtocol</span></span>
  ...
  <span class="m_8762435891985121735m_2981084392784924051pl-k" style="box-sizing:border-box">associatedtype</span> <span class="m_8762435891985121735m_2981084392784924051pl-v" style="box-sizing:border-box">SubSequence</span> : <span class="m_8762435891985121735m_2981084392784924051pl-e" style="box-sizing:border-box"><span class="m_8762435891985121735m_2981084392784924051pl-c1" style="box-sizing:border-box">Sequence</span>   <span class="m_8762435891985121735m_2981084392784924051pl-c" style="box-sizing:border-box">// currently ill-formed, but should be possible</span></span>
<span class="m_8762435891985121735m_2981084392784924051pl-e" style="box-sizing:border-box"><span class="m_8762435891985121735m_2981084392784924051pl-c" style="box-sizing:border-box"></span></span>}</span></font></pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px"><span style="background-color:rgba(255,255,255,0)">The compiler currently rejects this protocol, which is unfortunate: it effectively pushes the <code style="box-sizing:border-box;padding:0.2em 0px;margin:0px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">SubSequence</code>-must-be-a-<code style="box-sizing:border-box;padding:0.2em 0px;margin:0px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Sequ<wbr>ence</code> requirement into every consumer of <code style="box-sizing:border-box;padding:0.2em 0px;margin:0px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">SubSequence</code>, and does not communicate the intent of this abstraction well.&quot;</span></p><h3 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25"><a id="m_8762435891985121735m_2981084392784924051user-content-nested-generics" class="m_8762435891985121735m_2981084392784924051anchor" href="https://github.com/apple/swift/blob/master/docs/GenericsManifesto.md#nested-generics" style="box-sizing:border-box;text-decoration:none;float:left;padding-right:4px;line-height:1" target="_blank"><u></u><u></u><font color="#000000" size="3"><span style="background-color:rgba(255,255,255,0)"><u></u><u></u></span></font></a></h3>It&#39;s actually slightly worse than the above implies: the standard library has a pile of underscore-prefixed protocols (e.g., _Sequence) specifically to dodge this restriction. They are ugly, and we want them to go away. Many of these places are marked with an ABI FIXME in the standard library sources. </div><div><br></div><div>Would someone like to write up a proposal for this feature? The syntax and basic semantics are pretty direct, but a proposal should also capture the expected effects on the standard library, particularly when combined with where clauses on associated types.</div><div><br></div><div>I also have a nagging feeling that we will need some form of restrictions on this feature for implementation reasons, e.g., because some recursive constraints will form unsolvable systems.</div><div><br></div><div>For reference, we&#39;ve already been implementing this feature. Some information about the compiler internal issues is captured at:</div><div><br></div><div>  <a href="https://gist.github.com/DougGregor/e7c4e7bb4465d6f5fa2b59be72dbdba6" target="_blank">https://gist.github.com/Doug<wbr>Gregor/e7c4e7bb4465d6f5fa2b59b<wbr>e72dbdba6</a></div><div><br></div><div>  - Doug</div><div><br></div><div><br></div><div><br><div>Sent from my iPhone</div></div></div><br>______________________________<wbr>_________________<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/mailma<wbr>n/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div>
</div></blockquote></div></span></div></blockquote></div><br></div>