<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">It could certainly be improved:<div class=""><br class=""></div><div class="">- In step 2, the compiler could propose a fixit for subscript where the unknown associated type is replaced by a placeholder.</div><div class="">- Fixits from steps 2, 3, and 4 should be combined together as a single fixit.</div><div class=""><br class=""></div><div class="">And with this: you add the conformance to your type, Xcode automatically suggest everything you need to add, and you then add it in one click.</div><div class=""><div><br class=""><blockquote type="cite" class=""><div class="">Le 17 sept. 2017 à 22:13, T.J. Usiyan &lt;<a href="mailto:griotspeak@gmail.com" class="">griotspeak@gmail.com</a>&gt; a écrit :</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">I guess the question is, "Do we want this to be the process we expect of and explain to newcomers?"</div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sun, Sep 17, 2017 at 7:32 PM, Michel Fortin via swift-evolution <span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div style="word-wrap:break-word" class=""><div style="word-wrap:break-word" class=""><span class=""><div class=""><blockquote type="cite" class=""><div class="">Le 17 sept. 2017 à 18:00, Félix Cloutier via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; a écrit :</div><br class="m_4409662905358194403Apple-interchange-newline"><div class=""><div style="word-wrap:break-word" class="">I found that for Sequence, but Sequence is far from the only protocol with default implementations, and not all of them have maintainers willing to write and update documentation to the degree that Apple will.</div></div></blockquote><br class=""></div></span><div class=""><div class="">How I do it is like this:</div><div class=""><br class=""></div><div class="">1. Make a dummy struct (or class) that claim conformance to a protocol:</div><div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Mono';color:rgb(195,89,0);background-color:rgb(255,252,249)" class=""><span style="color:rgb(54,86,138)" class="">struct</span><span style="" class="">&nbsp;Z:&nbsp;</span>Collection<span style="" class="">&nbsp;{</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Mono';background-color:rgb(255,252,249)" class="">}</div></div><div class=""><br class=""></div><div class="">2. Compiling, then deciphering the errors tells me that type deduction doesn't work for associated type `Index` because there is no subscript. So I add one:</div><div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Mono';color:rgb(195,89,0);background-color:rgb(255,252,249)" class=""><span style="color:rgb(54,86,138)" class="">struct</span><span style="" class="">&nbsp;Z:&nbsp;</span>Collection<span style="" class="">&nbsp;{</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Mono';background-color:rgb(255,252,249)" class=""><span class="m_4409662905358194403Apple-tab-span" style="white-space:pre-wrap">        </span><span style="color:rgb(54,86,138)" class="">subscript</span>&nbsp;(index:&nbsp;<span style="color:rgb(195,89,0)" class="">Int</span>) -&gt;&nbsp;<span style="color:rgb(195,89,0)" class="">Int</span>&nbsp;{</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Mono';background-color:rgb(255,252,249)" class=""><span class="m_4409662905358194403Apple-tab-span" style="white-space:pre-wrap">                </span><span style="color:rgb(54,86,138)" class="">get</span>&nbsp;{&nbsp;<span style="color:rgb(54,86,138)" class="">return</span>&nbsp;index }</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Mono';background-color:rgb(255,252,249)" class=""><span class="m_4409662905358194403Apple-tab-span" style="white-space:pre-wrap">        </span>}</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Mono';background-color:rgb(255,252,249)" class="">}</div></div><div class=""><br class=""></div><div class="">3. Compiling again, I now get a suggestion (fixit) telling me to add `startIndex` and `endIndex`. I add the suggested code:</div><div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Mono';color:rgb(195,89,0);background-color:rgb(255,252,249)" class=""><span style="color:rgb(54,86,138)" class="">struct</span><span style="" class="">&nbsp;Z:&nbsp;</span>Collection<span style="" class="">&nbsp;{</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Mono';background-color:rgb(255,252,249)" class=""><span class="m_4409662905358194403Apple-tab-span" style="white-space:pre-wrap">        </span><span style="color:rgb(54,86,138)" class="">var</span>&nbsp;startIndex:&nbsp;<span style="color:rgb(195,89,0)" class="">Int</span></div><div style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica;background-color:rgb(255,252,249);min-height:14px" class=""><br class=""></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Mono';background-color:rgb(255,252,249)" class=""><span class="m_4409662905358194403Apple-tab-span" style="white-space:pre-wrap">        </span><span style="color:rgb(54,86,138)" class="">var</span>&nbsp;endIndex:&nbsp;<span style="color:rgb(195,89,0)" class="">Int</span></div><div style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica;background-color:rgb(255,252,249);min-height:14px" class=""><br class=""></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Mono';background-color:rgb(255,252,249)" class=""><span class="m_4409662905358194403Apple-tab-span" style="white-space:pre-wrap">        </span><span style="color:rgb(54,86,138)" class="">subscript</span>&nbsp;(index:&nbsp;<span style="color:rgb(195,89,0)" class="">Int</span>) -&gt;&nbsp;<span style="color:rgb(195,89,0)" class="">Int</span>&nbsp;{</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Mono';background-color:rgb(255,252,249)" class=""><span class="m_4409662905358194403Apple-tab-span" style="white-space:pre-wrap">                </span><span style="color:rgb(54,86,138)" class="">get</span>&nbsp;{&nbsp;<span style="color:rgb(54,86,138)" class="">return</span>&nbsp;index }</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Mono';background-color:rgb(255,252,249)" class=""><span class="m_4409662905358194403Apple-tab-span" style="white-space:pre-wrap">        </span>}</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Mono';background-color:rgb(255,252,249)" class="">}</div></div><div class=""><br class=""></div><div class="">4. Compiling again, I get another suggestion (fixit) telling me I'm missing `index(after:)`. I add it and write an implementation inside the braces. And here I am:</div><div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Mono';color:rgb(195,89,0);background-color:rgb(255,252,249)" class=""><span style="color:rgb(54,86,138)" class="">struct</span><span style="" class="">&nbsp;Z:&nbsp;</span>Collection<span style="" class="">&nbsp;{</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Mono';background-color:rgb(255,252,249)" class=""><span class="m_4409662905358194403Apple-tab-span" style="white-space:pre-wrap">        </span><span style="color:rgb(54,86,138)" class="">func</span>&nbsp;index(after i:&nbsp;<span style="color:rgb(195,89,0)" class="">Int</span>) -&gt;&nbsp;<span style="color:rgb(195,89,0)" class="">Int</span>&nbsp;{</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Mono';background-color:rgb(255,252,249)" class=""><span class="m_4409662905358194403Apple-tab-span" style="white-space:pre-wrap">                </span><span style="color:rgb(54,86,138)" class="">return</span>&nbsp;i +&nbsp;<span style="color:rgb(54,86,138)" class="">1</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Mono';background-color:rgb(255,252,249)" class=""><span class="m_4409662905358194403Apple-tab-span" style="white-space:pre-wrap">        </span>}</div><div style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica;background-color:rgb(255,252,249);min-height:14px" class=""><br class=""></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Mono';background-color:rgb(255,252,249)" class=""><span class="m_4409662905358194403Apple-tab-span" style="white-space:pre-wrap">        </span><span style="color:rgb(54,86,138)" class="">var</span>&nbsp;startIndex:&nbsp;<span style="color:rgb(195,89,0)" class="">Int</span></div><div style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica;background-color:rgb(255,252,249);min-height:14px" class=""><br class=""></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Mono';background-color:rgb(255,252,249)" class=""><span class="m_4409662905358194403Apple-tab-span" style="white-space:pre-wrap">        </span><span style="color:rgb(54,86,138)" class="">var</span>&nbsp;endIndex:&nbsp;<span style="color:rgb(195,89,0)" class="">Int</span></div><div style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica;background-color:rgb(255,252,249);min-height:14px" class=""><br class=""></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Mono';background-color:rgb(255,252,249)" class=""><span class="m_4409662905358194403Apple-tab-span" style="white-space:pre-wrap">        </span><span style="color:rgb(54,86,138)" class="">subscript</span>&nbsp;(index:&nbsp;<span style="color:rgb(195,89,0)" class="">Int</span>) -&gt;&nbsp;<span style="color:rgb(195,89,0)" class="">Int</span>&nbsp;{</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Mono';background-color:rgb(255,252,249)" class=""><span class="m_4409662905358194403Apple-tab-span" style="white-space:pre-wrap">                </span><span style="color:rgb(54,86,138)" class="">get</span>&nbsp;{&nbsp;<span style="color:rgb(54,86,138)" class="">return</span>&nbsp;index }</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Mono';background-color:rgb(255,252,249)" class=""><span class="m_4409662905358194403Apple-tab-span" style="white-space:pre-wrap">        </span>}</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:'Fira Mono';background-color:rgb(255,252,249)" class="">}</div></div><div class=""><br class=""></div><div class="">5. And now it compiles. Hurray!</div><div class=""><br class=""></div><div class="">I made a collection type and did not have to read any documentation at all. The hardest step is the first one where you have to figure out how to make deduction work for the associated types based on the error messages.</div><span class="HOEnZb"><font color="#888888" class=""><div class=""><br class=""></div></font></span></div><span class="HOEnZb"><font color="#888888" class=""><br class=""><div class=""><div style="word-wrap:break-word" class=""><div style="word-wrap:break-word" class=""><div style="word-wrap:break-word" class=""><div style="font-family:Helvetica;font-variant-ligatures:normal;font-variant-east-asian:normal;line-height:normal;text-align:-webkit-auto;word-wrap:break-word" class=""><span class="m_4409662905358194403Apple-style-span" style="border-collapse:separate;font-variant-ligatures:normal;font-variant-east-asian:normal;line-height:normal;border-spacing:0px"><div style="word-wrap:break-word" class=""><span class="m_4409662905358194403Apple-style-span" style="border-collapse:separate;font-variant-ligatures:normal;font-variant-east-asian:normal;line-height:normal;text-align:-webkit-auto;border-spacing:0px"><div style="word-wrap:break-word" class=""><span class="m_4409662905358194403Apple-style-span" style="border-collapse:separate;font-variant-ligatures:normal;font-variant-east-asian:normal;line-height:normal;text-align:-webkit-auto;border-spacing:0px"><div style="word-wrap:break-word" class="">--&nbsp;<br class="">Michel Fortin</div><div style="word-wrap:break-word" class=""><span style="text-align:-webkit-auto" class=""><a href="https://michelf.ca/" target="_blank" class="">https://michelf.ca</a></span></div><div class=""><br class=""></div></span></div></span></div></span></div></div></div></div></div></font></span></div></div><span class="HOEnZb"><font color="#888888" class=""><br class=""><br class=""><div class="">
<div style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; word-wrap: break-word;" class=""><div style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; word-wrap: break-word;" class=""><div style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; word-wrap: break-word;" class=""><div style="font-family: Helvetica; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-east-asian: normal; font-variant-position: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; word-wrap: break-word;" class=""><span class="m_4409662905358194403Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-east-asian: normal; font-variant-position: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; border-spacing: 0px;"><div style="word-wrap:break-word" class=""><span class="m_4409662905358194403Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-east-asian: normal; font-variant-position: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; border-spacing: 0px;"><div style="word-wrap:break-word" class=""><span class="m_4409662905358194403Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-east-asian: normal; font-variant-position: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; border-spacing: 0px;"><div style="word-wrap:break-word" class="">--&nbsp;<br class="">Michel Fortin</div><div style="word-wrap:break-word" class=""><span style="text-align:-webkit-auto" class=""><a href="https://michelf.ca/" target="_blank" class="">https://michelf.ca</a></span></div></span></div></span></div></span></div></div></div></div>
</div>
<br class=""></font></span></div><br class="">______________________________<wbr class="">_________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/<wbr class="">mailman/listinfo/swift-<wbr class="">evolution</a><br class="">
<br class=""></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; border-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px;"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; border-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px;"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; border-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px;"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">--&nbsp;<br class="">Michel Fortin</div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><span style="text-align: -webkit-auto;" class=""><a href="https://michelf.ca" class="">https://michelf.ca</a></span></div></span></div></span></div></span></div></div></div></div>
</div>
<br class=""></div></body></html>