<html><body><div>Am 05. Mai 2016 um 14:59 schrieb Matthew Johnson <matthew@anandabits.com>:<br><br><div><blockquote type="cite"><div class="msg-quote" dir="auto"><div><br><br>Sent from my iPad</div><div><br>On May 5, 2016, at 7:30 AM, Thorsten Seitz <<a href="mailto:tseitz42@icloud.com" data-mce-href="mailto:tseitz42@icloud.com">tseitz42@icloud.com</a>> wrote:<br><br></div><blockquote type="cite"><div>To me it reads as a constraint on R. Otherwise we would have to write `protocol R where … : Q where …, S where … { … }` which would not only be confusing but would not make much sense IMHO because I want to be able to write constraints which combine associated types from R, Q and S, i.e. from all sources contributing to R.</div></blockquote><div><br></div>My early post was poorly worded. It reads as a constraint on the associated types R inherits (from Q in this example). You would be able to relate any inherited associated types to each other here if desired. Any new associated types introduced by R should be constrained where they are introduced.</div></blockquote></div><div><span><br data-mce-bogus="1"></span></div><div><span><div>Ah, yes, you are right, of course!<br></div><div><span>New associated types introduced by R do have their own where clause, so that would be the proper place to constrain them. <br data-mce-bogus="1"></span></div><div><span><span><span><br data-mce-bogus="1"></span></span></span></div> </span><blockquote type="cite"><div class="msg-quote" dir="auto"><div><br><blockquote type="cite"><div><div class="">Answering Doug’s question: I’d like the name lookup to start in R and to be able to refer to an associated type newly defined in R.</div></div></blockquote><div><br></div><div>This seems confusing to me. The associated type has not been introduced until inside the body of R. It doesn't make sense to allow them to be constrained prior to introduction and it offers no additional functionality. Separating the constraints on inherited associated types from the constraints on newly introduced associated types adds clarity and readability IMO. Lookup should only consider inherited protocols.</div></div></div></blockquote></div><div><span><br data-mce-bogus="1"></span></div><div><span>I totally agree. </span></div><div><span><br data-mce-bogus="1"></span></div><div><span>-Thorsten</span></div><div><span><br data-mce-bogus="1"></span></div><div><span><br></span><blockquote type="cite"><div class="msg-quote" dir="auto"><div><div></div><div><br></div><br><blockquote type="cite"><div><div class=""><br class=""></div><div class="">-Thorsten</div><div class=""><br class=""><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">Am 03.05.2016 um 14:03 schrieb Matthew Johnson via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="" data-mce-href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>>:</div><br class="Apple-interchange-newline"><div class=""><div dir="auto" class=""><div class=""><br class=""><br class="">Sent from my iPad</div><div class=""><br class="">On May 3, 2016, at 3:37 AM, Douglas Gregor via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="" data-mce-href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div class=""><br class=""><br class="">Sent from my iPhone</div><div class=""><br class="">On May 2, 2016, at 3:50 PM, David Hart <<a href="mailto:david@hartbit.com" class="" data-mce-href="mailto:david@hartbit.com">david@hartbit.com</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class="">Hi Doug,<div class=""><br class=""></div><div class="">In the latest version of the proposal, which is now linked to a pull request, I mentioned in the Detail Design section that the following syntax be valid:</div><div class=""><br class=""></div><div class="">protocol R : Q where AssocType : P {<br class=""> // …<br class="">}</div><div class=""><br class=""></div><div class="">Can you read through that part of the proposal and let me know if it is descriptive enough?</div></div></blockquote><div class=""><br class=""></div>I think you need to clarify the intended name lookup semantics. Does name lookup for "AssocType" start its lookup in R or in Q? If the former, can one refer to an associated type newly defined in R?</div></blockquote><div class=""><br class=""></div>To me this syntax reads as a constraint on Q only. If we need a constraint on associated types defined in R the constraint should be attached to the definition.<div class=""><br class=""><blockquote type="cite" class=""><div class=""><div class=""><br class=""></div><div class=""> - Doug</div><div class=""><br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class=""><div class=""><br class=""></div><div class="">David.</div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 26 Apr 2016, at 05:28, Douglas Gregor <<a href="mailto:dgregor@apple.com" class="" data-mce-href="mailto:dgregor@apple.com">dgregor@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="word-wrap: break-word;" class="" data-mce-style="word-wrap: break-word;"><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Apr 24, 2016, at 1:34 PM, David Hart via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="" data-mce-href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="word-wrap: break-word;" class="" data-mce-style="word-wrap: break-word;">I wrote the proposal which was discussed to introduce generic constraints for associated types. I’d like to get some feedback on it and get it ready before submitting it:<div class=""><br class=""></div><div class=""><h1 style="box-sizing: border-box; font-size: 2.25em; line-height: 1.2; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #eeeeee; color: #333333; font-family: 'helvetica neue' , 'helvetica' , 'segoe ui' , 'arial' , 'freesans' , sans-serif , 'apple color emoji' , 'segoe ui emoji' , 'segoe ui symbol'; background-color: #ffffff; margin: 0px 0px 16px 0px;" class="" data-mce-style="box-sizing: border-box; font-size: 2.25em; line-height: 1.2; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #eeeeee; color: #333333; font-family: 'helvetica neue' , 'helvetica' , 'segoe ui' , 'arial' , 'freesans' , sans-serif , 'apple color emoji' , 'segoe ui emoji' , 'segoe ui symbol'; background-color: #ffffff; margin: 0px 0px 16px 0px;">More Powerful Constraints for Associated Types</h1><ul style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: 'helvetica neue' , 'helvetica' , 'segoe ui' , 'arial' , 'freesans' , sans-serif , 'apple color emoji' , 'segoe ui emoji' , 'segoe ui symbol'; font-size: 16px; background-color: #ffffff;" class="" data-mce-style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: 'helvetica neue' , 'helvetica' , 'segoe ui' , 'arial' , 'freesans' , sans-serif , 'apple color emoji' , 'segoe ui emoji' , 'segoe ui symbol'; font-size: 16px; background-color: #ffffff;"><li style="box-sizing: border-box;" class="" data-mce-style="box-sizing: border-box;">Proposal: <a href="https://github.com/hartbit/swift-evolution/blob/master/proposals/XXXX-powerful-constraints-associated-types.md" style="box-sizing: border-box; background-color: transparent; color: #4078c0; text-decoration: none;" class="" data-mce-href="https://github.com/hartbit/swift-evolution/blob/master/proposals/XXXX-powerful-constraints-associated-types.md" data-mce-style="box-sizing: border-box; background-color: transparent; color: #4078c0; text-decoration: none;">SE-XXXX</a><br data-mce-bogus="1"></li><li style="box-sizing: border-box;" class="" data-mce-style="box-sizing: border-box;">Author(s): <a href="http://github.com/hartbit" style="box-sizing: border-box; background-color: transparent; color: #4078c0; text-decoration: none;" class="" data-mce-href="http://github.com/hartbit" data-mce-style="box-sizing: border-box; background-color: transparent; color: #4078c0; text-decoration: none;">David Hart</a><br data-mce-bogus="1"></li><li style="box-sizing: border-box;" class="" data-mce-style="box-sizing: border-box;">Status: <strong style="box-sizing: border-box;" class="" data-mce-style="box-sizing: border-box;">TBD</strong></li><li style="box-sizing: border-box;" class="" data-mce-style="box-sizing: border-box;">Review manager: TBD</li></ul><h2 style="box-sizing: border-box; margin-top: 1em; margin-bottom: 16px; line-height: 1.225; font-size: 1.75em; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #eeeeee; color: #333333; font-family: 'helvetica neue' , 'helvetica' , 'segoe ui' , 'arial' , 'freesans' , sans-serif , 'apple color emoji' , 'segoe ui emoji' , 'segoe ui symbol'; background-color: #ffffff;" class="" data-mce-style="box-sizing: border-box; margin-top: 1em; margin-bottom: 16px; line-height: 1.225; font-size: 1.75em; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #eeeeee; color: #333333; font-family: 'helvetica neue' , 'helvetica' , 'segoe ui' , 'arial' , 'freesans' , sans-serif , 'apple color emoji' , 'segoe ui emoji' , 'segoe ui symbol'; background-color: #ffffff;"><a id="user-content-introduction" class="anchor" href="https://github.com/hartbit/swift-evolution/blob/master/proposals/XXXX-powerful-constraints-associated-types.md#introduction" style="box-sizing: border-box; background-color: transparent; color: #4078c0; text-decoration: none; display: inline-block; padding-right: 2px; margin-left: -18px; line-height: 1;" data-mce-href="https://github.com/hartbit/swift-evolution/blob/master/proposals/XXXX-powerful-constraints-associated-types.md#introduction" data-mce-style="box-sizing: border-box; background-color: transparent; color: #4078c0; text-decoration: none; display: inline-block; padding-right: 2px; margin-left: -18px; line-height: 1;"></a>Introduction</h2><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: 'helvetica neue' , 'helvetica' , 'segoe ui' , 'arial' , 'freesans' , sans-serif , 'apple color emoji' , 'segoe ui emoji' , 'segoe ui symbol'; font-size: 16px; background-color: #ffffff;" class="" data-mce-style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: 'helvetica neue' , 'helvetica' , 'segoe ui' , 'arial' , 'freesans' , sans-serif , 'apple color emoji' , 'segoe ui emoji' , 'segoe ui symbol'; font-size: 16px; background-color: #ffffff;">This proposal seeks to introduce a <code style="box-sizing: border-box; font-family: 'consolas' , 'liberation mono' , 'menlo' , 'courier' , monospace; font-size: 13.600000381469727px; 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;" class="" data-mce-style="box-sizing: border-box; font-family: 'consolas' , 'liberation mono' , 'menlo' , 'courier' , monospace; font-size: 13.600000381469727px; 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;">where</code> expression to associated types declarations to bring the same expressive power as generic type constraints.</p><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: 'helvetica neue' , 'helvetica' , 'segoe ui' , 'arial' , 'freesans' , sans-serif , 'apple color emoji' , 'segoe ui emoji' , 'segoe ui symbol'; font-size: 16px; background-color: #ffffff;" class="" data-mce-style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: 'helvetica neue' , 'helvetica' , 'segoe ui' , 'arial' , 'freesans' , sans-serif , 'apple color emoji' , 'segoe ui emoji' , 'segoe ui symbol'; font-size: 16px; background-color: #ffffff;"><em style="box-sizing: border-box;" class="" data-mce-style="box-sizing: border-box;">This proposal was discussed on the Swift Evolution list in the <a href="http://thread.gmane.org/gmane.comp.lang.swift.evolution/14243" style="box-sizing: border-box; background-color: transparent; color: #4078c0; text-decoration: none;" class="" data-mce-href="http://thread.gmane.org/gmane.comp.lang.swift.evolution/14243" data-mce-style="box-sizing: border-box; background-color: transparent; color: #4078c0; text-decoration: none;">[swift-evolution] [Completing Generics] Arbitrary requirements in protocols</a> thread.</em></p></div></div></div></blockquote>Believe it or not, I support this direction…</div><div class=""><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word;" class="" data-mce-style="word-wrap: break-word;"><div class=""><h2 style="box-sizing: border-box; margin-top: 1em; margin-bottom: 16px; line-height: 1.225; font-size: 1.75em; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #eeeeee; color: #333333; font-family: 'helvetica neue' , 'helvetica' , 'segoe ui' , 'arial' , 'freesans' , sans-serif , 'apple color emoji' , 'segoe ui emoji' , 'segoe ui symbol'; background-color: #ffffff;" class="" data-mce-style="box-sizing: border-box; margin-top: 1em; margin-bottom: 16px; line-height: 1.225; font-size: 1.75em; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #eeeeee; color: #333333; font-family: 'helvetica neue' , 'helvetica' , 'segoe ui' , 'arial' , 'freesans' , sans-serif , 'apple color emoji' , 'segoe ui emoji' , 'segoe ui symbol'; background-color: #ffffff;"><a id="user-content-motivation" class="anchor" href="https://github.com/hartbit/swift-evolution/blob/master/proposals/XXXX-powerful-constraints-associated-types.md#motivation" style="box-sizing: border-box; background-color: transparent; color: #4078c0; text-decoration: none; display: inline-block; padding-right: 2px; margin-left: -18px; line-height: 1;" data-mce-href="https://github.com/hartbit/swift-evolution/blob/master/proposals/XXXX-powerful-constraints-associated-types.md#motivation" data-mce-style="box-sizing: border-box; background-color: transparent; color: #4078c0; text-decoration: none; display: inline-block; padding-right: 2px; margin-left: -18px; line-height: 1;"></a>Motivation</h2><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: 'helvetica neue' , 'helvetica' , 'segoe ui' , 'arial' , 'freesans' , sans-serif , 'apple color emoji' , 'segoe ui emoji' , 'segoe ui symbol'; font-size: 16px; background-color: #ffffff;" class="" data-mce-style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: 'helvetica neue' , 'helvetica' , 'segoe ui' , 'arial' , 'freesans' , sans-serif , 'apple color emoji' , 'segoe ui emoji' , 'segoe ui symbol'; font-size: 16px; background-color: #ffffff;">Currently, associated type declarations can only express simple inheritance constraints and not the more sophisticated constraints available to generic types with the <code style="box-sizing: border-box; font-family: 'consolas' , 'liberation mono' , 'menlo' , 'courier' , monospace; font-size: 13.600000381469727px; 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;" class="" data-mce-style="box-sizing: border-box; font-family: 'consolas' , 'liberation mono' , 'menlo' , 'courier' , monospace; font-size: 13.600000381469727px; 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;">where</code> expression. Some designs, including many in the Standard Library, require more powerful constraints for associated types to be truly elegant. For example, the <code style="box-sizing: border-box; font-family: 'consolas' , 'liberation mono' , 'menlo' , 'courier' , monospace; font-size: 13.600000381469727px; 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;" class="" data-mce-style="box-sizing: border-box; font-family: 'consolas' , 'liberation mono' , 'menlo' , 'courier' , monospace; font-size: 13.600000381469727px; 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;">SequenceType</code> protocol can be declared as follows:</p><pre style="box-sizing: border-box; overflow: auto; font-family: 'consolas' , 'liberation mono' , 'menlo' , 'courier' , monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 16px; line-height: 1.45; padding: 16px; background-color: #f7f7f7; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: normal; color: #333333;" class="" data-mce-style="box-sizing: border-box; overflow: auto; font-family: 'consolas' , 'liberation mono' , 'menlo' , 'courier' , monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 16px; line-height: 1.45; padding: 16px; background-color: #f7f7f7; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: normal; color: #333333;"><code style="box-sizing: border-box; font-family: 'consolas' , 'liberation mono' , 'menlo' , 'courier' , monospace; font-size: 13.600000381469727px; padding: 0px; margin: 0px; background-color: transparent; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal; border: 0px; display: inline; line-height: inherit; word-wrap: normal;" class="" data-mce-style="box-sizing: border-box; font-family: 'consolas' , 'liberation mono' , 'menlo' , 'courier' , monospace; font-size: 13.600000381469727px; padding: 0px; margin: 0px; background-color: transparent; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal; border: 0px; display: inline; line-height: inherit; word-wrap: normal;">protocol Sequence {
associatedtype Iterator : IteratorProtocol
associatedtype SubSequence : Sequence where SubSequence.Iterator.Element == Iterator.Element
...
}
</code></pre><h2 style="box-sizing: border-box; margin-top: 1em; margin-bottom: 16px; line-height: 1.225; font-size: 1.75em; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #eeeeee; color: #333333; font-family: 'helvetica neue' , 'helvetica' , 'segoe ui' , 'arial' , 'freesans' , sans-serif , 'apple color emoji' , 'segoe ui emoji' , 'segoe ui symbol'; background-color: #ffffff;" class="" data-mce-style="box-sizing: border-box; margin-top: 1em; margin-bottom: 16px; line-height: 1.225; font-size: 1.75em; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #eeeeee; color: #333333; font-family: 'helvetica neue' , 'helvetica' , 'segoe ui' , 'arial' , 'freesans' , sans-serif , 'apple color emoji' , 'segoe ui emoji' , 'segoe ui symbol'; background-color: #ffffff;"><a id="user-content-detail-design" class="anchor" href="https://github.com/hartbit/swift-evolution/blob/master/proposals/XXXX-powerful-constraints-associated-types.md#detail-design" style="box-sizing: border-box; background-color: transparent; color: #4078c0; text-decoration: none; display: inline-block; padding-right: 2px; margin-left: -18px; line-height: 1;" data-mce-href="https://github.com/hartbit/swift-evolution/blob/master/proposals/XXXX-powerful-constraints-associated-types.md#detail-design" data-mce-style="box-sizing: border-box; background-color: transparent; color: #4078c0; text-decoration: none; display: inline-block; padding-right: 2px; margin-left: -18px; line-height: 1;"></a>Detail Design</h2><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: 'helvetica neue' , 'helvetica' , 'segoe ui' , 'arial' , 'freesans' , sans-serif , 'apple color emoji' , 'segoe ui emoji' , 'segoe ui symbol'; font-size: 16px; background-color: #ffffff;" class="" data-mce-style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: 'helvetica neue' , 'helvetica' , 'segoe ui' , 'arial' , 'freesans' , sans-serif , 'apple color emoji' , 'segoe ui emoji' , 'segoe ui symbol'; font-size: 16px; background-color: #ffffff;">With this proposal, the grammar for protocols associated types would be modified to:</p><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: 'helvetica neue' , 'helvetica' , 'segoe ui' , 'arial' , 'freesans' , sans-serif , 'apple color emoji' , 'segoe ui emoji' , 'segoe ui symbol'; font-size: 16px; background-color: #ffffff;" class="" data-mce-style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: 'helvetica neue' , 'helvetica' , 'segoe ui' , 'arial' , 'freesans' , sans-serif , 'apple color emoji' , 'segoe ui emoji' , 'segoe ui symbol'; font-size: 16px; background-color: #ffffff;"><em style="box-sizing: border-box;" class="" data-mce-style="box-sizing: border-box;">protocol-associated-type-declaration</em> → <em style="box-sizing: border-box;" class="" data-mce-style="box-sizing: border-box;">attributes<span style="box-sizing: border-box; font-size: 12px; line-height: 0; position: relative; vertical-align: baseline; bottom: -0.25em;" class="" data-mce-style="box-sizing: border-box; font-size: 12px; line-height: 0; position: relative; vertical-align: baseline; bottom: -0.25em;">opt</span></em> <em style="box-sizing: border-box;" class="" data-mce-style="box-sizing: border-box;">access-level-modifier<span style="box-sizing: border-box; font-size: 12px; line-height: 0; position: relative; vertical-align: baseline; bottom: -0.25em;" class="" data-mce-style="box-sizing: border-box; font-size: 12px; line-height: 0; position: relative; vertical-align: baseline; bottom: -0.25em;">opt</span></em> <strong style="box-sizing: border-box;" class="" data-mce-style="box-sizing: border-box;">associatedtype</strong> <em style="box-sizing: border-box;" class="" data-mce-style="box-sizing: border-box;">typealias-name</em> <em style="box-sizing: border-box;" class="" data-mce-style="box-sizing: border-box;">type-inheritance-clause<span style="box-sizing: border-box; font-size: 12px; line-height: 0; position: relative; vertical-align: baseline; bottom: -0.25em;" class="" data-mce-style="box-sizing: border-box; font-size: 12px; line-height: 0; position: relative; vertical-align: baseline; bottom: -0.25em;">opt</span></em> <em style="box-sizing: border-box;" class="" data-mce-style="box-sizing: border-box;">typealias-assignment<span style="box-sizing: border-box; font-size: 12px; line-height: 0; position: relative; vertical-align: baseline; bottom: -0.25em;" class="" data-mce-style="box-sizing: border-box; font-size: 12px; line-height: 0; position: relative; vertical-align: baseline; bottom: -0.25em;">opt</span></em> <em style="box-sizing: border-box;" class="" data-mce-style="box-sizing: border-box;">requirement-clause<span style="box-sizing: border-box; font-size: 12px; line-height: 0; position: relative; vertical-align: baseline; bottom: -0.25em;" class="" data-mce-style="box-sizing: border-box; font-size: 12px; line-height: 0; position: relative; vertical-align: baseline; bottom: -0.25em;">opt</span></em></p><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: 'helvetica neue' , 'helvetica' , 'segoe ui' , 'arial' , 'freesans' , sans-serif , 'apple color emoji' , 'segoe ui emoji' , 'segoe ui symbol'; font-size: 16px; background-color: #ffffff;" class="" data-mce-style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: 'helvetica neue' , 'helvetica' , 'segoe ui' , 'arial' , 'freesans' , sans-serif , 'apple color emoji' , 'segoe ui emoji' , 'segoe ui symbol'; font-size: 16px; background-color: #ffffff;">The new <code style="box-sizing: border-box; font-family: 'consolas' , 'liberation mono' , 'menlo' , 'courier' , monospace; font-size: 13.600000381469727px; 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;" class="" data-mce-style="box-sizing: border-box; font-family: 'consolas' , 'liberation mono' , 'menlo' , 'courier' , monospace; font-size: 13.600000381469727px; 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;">requirement-clause</code> is then used by the compiler to validate the associated types of conforming types.</p></div></div></div></blockquote>The only thing that bothers me about this syntax is that I have to introduce an associated type to add requirements. For example, what if I want my inheriting protocol to add a requirement to an existing associated type?</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class="" data-mce-style="margin: 0 0 0 40px; border: none; padding: 0px;"><div class=""><span style="font-family: Menlo;" data-mce-style="font-family: Menlo;" face="Menlo">protocol P { }</span></div><div class=""><span style="font-family: Menlo;" data-mce-style="font-family: Menlo;" face="Menlo"><br class=""></span></div><div class=""><span style="font-family: Menlo;" data-mce-style="font-family: Menlo;" face="Menlo">protocol Q {</span></div><div class=""><span style="font-family: Menlo;" data-mce-style="font-family: Menlo;" face="Menlo"> typealias AssocType</span></div><div class=""><span style="font-family: Menlo;" data-mce-style="font-family: Menlo;" face="Menlo">}</span></div><div class=""><span style="font-family: Menlo;" data-mce-style="font-family: Menlo;" face="Menlo"><br class=""></span></div><div class=""><span style="font-family: Menlo;" data-mce-style="font-family: Menlo;" face="Menlo">protocol R : Q {</span></div><div class=""><span style="font-family: Menlo;" data-mce-style="font-family: Menlo;" face="Menlo"> // I want to just add “AssocType : P”, but I have to redeclare AssocType to do so</span></div><div class=""><span style="font-family: Menlo;" data-mce-style="font-family: Menlo;" face="Menlo"> typealias AssocType where AssocType : P</span></div><div class=""><span style="font-family: Menlo;" data-mce-style="font-family: Menlo;" face="Menlo">}</span></div></blockquote><div class=""><br class=""></div><div class="">Did you consider an alternate syntax that puts the where clause outside the braces, e.g.,</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class="" data-mce-style="margin: 0 0 0 40px; border: none; padding: 0px;"><div class=""><span style="font-family: Menlo;" data-mce-style="font-family: Menlo;" face="Menlo">protocol R : Q where AssocType : P {</span></div><div class=""><span style="font-family: Menlo;" data-mce-style="font-family: Menlo;" face="Menlo"> // …</span></div><div class=""><span style="font-family: Menlo;" data-mce-style="font-family: Menlo;" face="Menlo">}</span></div></blockquote><div class=""><br class=""></div><div class="">There are two things I like about this. First, it breaks the unnecessary link between an associated type and a (possibly unrelated) where clause, eliminating the need to redeclare associated types in inheriting protocols. Second, it’s effectively the same syntax as constrained extensions, which have a similar feel.</div><div class=""><br class=""></div><div class="">Note that, if we do the above, I’d love to make it an error to define a new associated type with the same name as an associated type in an inherited protocol. It’s odd that we do so, and IIRC the only use case for it is to add requirement to an “existing” associated type.</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space: pre;" data-mce-style="white-space: pre;"> </span>- Doug</div><div class=""><br class=""></div><br class=""></div></div></blockquote></div><br class=""></div></div></blockquote></div></div></div></blockquote><blockquote type="cite" class=""><div class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a href="mailto:swift-evolution@swift.org" class="" data-mce-href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="" data-mce-href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div></blockquote></div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="" data-mce-href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" data-mce-href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></div></div></blockquote></div></div></blockquote></div></div></body></html>