<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Mon, Aug 21, 2017 at 5:51 AM David Hart via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></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><blockquote type="cite"><div>On 21 Aug 2017, at 13:36, Adrian Zubarev <<a href="mailto:adrian.zubarev@devandartist.com" target="_blank">adrian.zubarev@devandartist.com</a>> wrote:</div><br class="m_7474794349195607222Apple-interchange-newline"><div><div class="m_7474794349195607222bloop_markdown" style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254)"><p style="margin:15px 0px">It’s part of Generalized Existentials, but does not make it complete. I think it would be worth adding more and more functionality to existentials every year. We started first with reshaping the syntax. This year we added support for classes. I think next year would be good to have<span class="m_7474794349195607222Apple-converted-space"> </span><code style="font-family:Menlo,Consolas,'Liberation Mono',Courier,monospace;font-size:10pt;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;background-color:rgb(248,248,248);color:inherit;border:1px solid rgb(234,234,234);margin:0px 2px;padding:0px 5px;word-break:normal;word-wrap:normal">where</code><span class="m_7474794349195607222Apple-converted-space"> </span>clause support for typealiases.<span class="m_7474794349195607222Apple-converted-space"> </span></p><p style="margin:15px 0px">I understand the complexity of that particular feature, and it’s a no-go for me to help on the implementation, but I’m willing to drive the discussion and the proposal forward with other co-authors. :)</p><p style="margin:15px 0px">Hasn’t it been said that the implementation must be at least a *proof-of-concept* if the complexity is very high?</p></div></div></blockquote></div></div><div style="word-wrap:break-word"><div><div>I’d love to have this feature. But I’m not sure even a partway proposal will get to review with the laser-focus on ABI Stability + Concurrency. I don’t want to spend time co-authoring a proposal if it is going to be out of scope anyway. Perhaps Doug (CC) can give us some ideas.</div></div></div></blockquote><div><br></div><div>For what it's worth, the updated README on swift-evolution says:</div><div><br></div><div>"Beyond ABI stability (which focuses mostly on getting a bunch of low-level implementation details of the language finalized), in Swift 5 the evolution process welcomes additions that improve the overall usability of the language and standard library"</div><div><br></div><div>So it sounds like they're willing to consider proposals outside of ABI+concurrency—and though I can't speak for the core team's motivation, it seems like requiring an implementation before formal review means that proposals beyond their primary focus have a greater chance of making it into the language than they did before.</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><blockquote type="cite"><div><div class="m_7474794349195607222bloop_markdown" style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254)"><p style="margin:15px 0px">And my second question is: Wouldn’t the existence of this feature reshape some parts of the standard library, isn’t that affecting some major goals of Swift 5?</p></div></div></blockquote></div></div><div style="word-wrap:break-word"><div>Yes. But that also true of many other language feature. But the Standard Library still needs to be set in stone at some point or another.</div></div><div style="word-wrap:break-word"><div><br><blockquote type="cite"><div><div class="m_7474794349195607222bloop_markdown" style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254)"><p style="margin:15px 0px">It would be nice if someone from the core team can clarify if the<span class="m_7474794349195607222Apple-converted-space"> </span><code style="font-family:Menlo,Consolas,'Liberation Mono',Courier,monospace;font-size:10pt;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;background-color:rgb(248,248,248);color:inherit;border:1px solid rgb(234,234,234);margin:0px 2px;padding:0px 5px;word-break:normal;word-wrap:normal">where</code><span class="m_7474794349195607222Apple-converted-space"> </span>clause is out of scope for Swift 5 or not.</p></div></div></blockquote></div></div><div style="word-wrap:break-word"><div><div>Agreed.</div></div></div><div style="word-wrap:break-word"><div><br><blockquote type="cite"><div><div class="m_7474794349195607222bloop_original_html" style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254)"><div id="m_7474794349195607222bloop_sign_1503314850459755776" class="m_7474794349195607222bloop_sign"></div><br><p class="m_7474794349195607222airmail_on" style="margin:15px 0px">Am 21. August 2017 um 12:51:48, David Hart (<a href="mailto:david@hartbit.com" style="color:rgb(65,131,196);background-color:inherit;text-decoration:none" target="_blank">david@hartbit.com</a>) schrieb:</p><blockquote type="cite" class="m_7474794349195607222clean_bq" style="margin:15px 0px"><span style="margin-top:0px;margin-bottom:0px"><div style="word-wrap:break-word"><div></div><div><br><div><blockquote type="cite" style="margin:15px 0px"><div style="margin-top:0px">On 21 Aug 2017, at 11:41, Adrian Zubarev <<a href="mailto:adrian.zubarev@devandartist.com" style="color:rgb(65,131,196);background-color:inherit;text-decoration:none" target="_blank">adrian.zubarev@devandartist.com</a>> wrote:</div><br class="m_7474794349195607222Apple-interchange-newline"><div style="margin-bottom:0px"><div id="m_7474794349195607222bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px">Yes, `where` clause is welcome to typealises (including generic ones) and existentials in general. I would love to help on such proposal. I think David Hart is also interested in this one. (cc)</div></div></blockquote><div><br></div><div>Yes, this basically seems like<span class="m_7474794349195607222Apple-converted-space"> </span><b>Generalized Existentials</b><span class="m_7474794349195607222Apple-converted-space"> </span>to me and is mentioned in the <a href="https://github.com/apple/swift/blob/master/docs/GenericsManifesto.md" style="color:rgb(65,131,196);background-color:inherit;text-decoration:none" target="_blank">Generics Manifesto</a>. It’s a feature I hold very dear but:</div><div><br></div><div><ul class="m_7474794349195607222MailOutline" style="margin:15px 0px"><li style="margin:15px 0px">It’s a very difficult feature to implement and I think Doug Gregor is the only/best person to do it</li><li style="margin:15px 0px">I think its pretty much out of scope for Swift 5 (it’s not required for ABI Stability)</li></ul><div><br></div><div>As a result, I’d be very surprised if this topic got any discussion or implementation time during the Swift 5 timeframe.</div></div><blockquote type="cite" style="margin:15px 0px"><div style="margin-top:0px;margin-bottom:0px"><p class="m_7474794349195607222airmail_on" style="margin:15px 0px;font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Am 21. August 2017 um 11:38:14, Gor Gyolchanyan via swift-evolution (<a href="mailto:swift-evolution@swift.org" style="color:rgb(65,131,196);background-color:inherit;text-decoration:none" target="_blank">swift-evolution@swift.org</a>) schrieb:</p><blockquote type="cite" class="m_7474794349195607222clean_bq" style="margin:15px 0px;font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="margin-top:0px;margin-bottom:0px;word-wrap:break-word"><div></div><div><span>Hello, Swift community!</span><div><span><br></span></div><div><span>I'd like to start a discussion about a possibility of constrained protocol aliases. The declaration would look like this:</span></div><div><span><br></span></div><div><div><span><font face="Menlo"><font color="#941751">typealias</font><span class="m_7474794349195607222Apple-converted-space"> </span><font color="#008F00">BinaryProtocol</font><span class="m_7474794349195607222Apple-converted-space"> </span>=<span class="m_7474794349195607222Apple-converted-space"> </span><font color="#008F00">RandomAccessCollection</font><span class="m_7474794349195607222Apple-converted-space"> </span>&<span class="m_7474794349195607222Apple-converted-space"> </span><font color="#008F00">MutablCollection</font><span class="m_7474794349195607222Apple-converted-space"> </span>&<span class="m_7474794349195607222Apple-converted-space"> </span><font color="#008F00">RangeReplaceableCollection</font><span class="m_7474794349195607222Apple-converted-space"> </span><font color="#941751">where</font> <font color="#008F00">Binary</font>.<font color="#008F00">Index</font><span class="m_7474794349195607222Apple-converted-space"> </span>==<span class="m_7474794349195607222Apple-converted-space"> </span><font color="#008F00">Int</font>,<span class="m_7474794349195607222Apple-converted-space"> </span><font color="#008F00">Binary</font>.<font color="#008F00">Element</font><span class="m_7474794349195607222Apple-converted-space"> </span>==<span class="m_7474794349195607222Apple-converted-space"> </span><font color="#008F00">Bool</font></font></span></div></div><div><br></div><div>The syntax and semantics of this declaration are exactly the same as an analogous<span class="m_7474794349195607222Apple-converted-space"> </span><font color="#941751" face="Menlo">associatedtype</font><span class="m_7474794349195607222Apple-converted-space"> </span>declaration inside a protocol.</div><div>In the example above, the type<span class="m_7474794349195607222Apple-converted-space"> </span><font face="Menlo" color="#008F00">BinaryProtocol</font> represents a logical array of bits and is a generic-only protocol that is usable in any context where an integer-indexed mutable range-replaceable random-access collection is expected.</div><div>Now, it can be used in a very concise and elegant way:</div><div><br></div><div><font face="Menlo"><font color="#941751">public</font><span class="m_7474794349195607222Apple-converted-space"> </span><font color="#941751">protocol</font><span class="m_7474794349195607222Apple-converted-space"> </span><font color="#008F00">BinaryInitializable</font><span class="m_7474794349195607222Apple-converted-space"> </span>{</font></div><div><font face="Menlo"><font color="#941751">init</font><<font color="#008F00">Binary</font>>(binary:<span class="m_7474794349195607222Apple-converted-space"> </span><font color="#008F00">Binary</font>)<span class="m_7474794349195607222Apple-converted-space"> </span><font color="#941751">where</font><span class="m_7474794349195607222Apple-converted-space"> </span><font color="#008F00">Binary</font>:<span class="m_7474794349195607222Apple-converted-space"> </span><font color="#008F00">BinaryProtocol</font></font></div><div><font face="Menlo">}</font></div><div><br></div><div>which would otherwise look very verbose and inelegant:</div><div><br></div><div><font face="Menlo"><font color="#941751">public</font><span class="m_7474794349195607222Apple-converted-space"> </span><font color="#941751">protocol</font><span class="m_7474794349195607222Apple-converted-space"> </span><font color="#008F00">BinaryInitializable</font><span class="m_7474794349195607222Apple-converted-space"> </span>{</font></div><div><font face="Menlo"><font color="#941751">init</font><<font color="#008F00">Binary</font>>(binary:<span class="m_7474794349195607222Apple-converted-space"> </span><font color="#008F00">Binary</font>)<span class="m_7474794349195607222Apple-converted-space"> </span><font color="#941751">where</font><span class="m_7474794349195607222Apple-converted-space"> </span>Binary: <font color="#008F00">RandomAccessCollection</font> & <font color="#008F00">MutablCollection</font> & <font color="#008F00">RangeReplaceableCollection,</font> <font color="#008F00">Binary</font>.<font color="#008F00">Index</font> == <font color="#008F00">Int</font>, <font color="#008F00">Binary</font>.<font color="#008F00">Element</font> == <font color="#008F00">Bool</font></font></div><div><font face="Menlo">}</font></div><div><div><br></div><div>Considering that smaller sets of constraints could be aliased to their own protocol and then composited into more complex aliases, this feature would dramatically improve readability and maintainability of code that uses complex constraints, that currently leads to arcane mess:</div><div><br></div><div><font face="Menlo"><font color="#941751">struct</font> <font color="#008F00">Mirror</font> {</font></div><div><ul class="m_7474794349195607222container" style="margin:0px;box-sizing:border-box;padding:0px;width:auto;list-style:none"><li style="margin:15px 0px"><font face="Menlo"><font color="#797979">/// ...</font></font></li><li style="margin:15px 0px"><font face="Menlo"><font color="#941751">init</font><<font color="#008F00">Subject</font>, <font color="#008F00">C</font> <font color="#941751">where</font> <font color="#008F00">C</font> : <font color="#008F00">Collection</font>, <font color="#008F00">C</font>.<font color="#008F00">Indices</font> : <font color="#008F00">Collection</font>, <font color="#008F00">C</font>.<font color="#008F00">SubSequence</font> : <font color="#008F00">Collection</font>, <font color="#008F00">C</font>.<font color="#008F00">Indices</font>.<font color="#008F00">Index</font> == <font color="#008F00">C</font>.<font color="#008F00">Index</font>, <font color="#008F00">C</font>.<font color="#008F00">Indices</font>.<font color="#008F00">SubSequence</font> == <font color="#008F00">C</font>.<font color="#008F00">Indices</font>, <font color="#008F00">C</font>.<font color="#008F00">Iterator</font>.<font color="#008F00">Element</font> == <font color="#008F00">Mirror</font>.<font color="#008F00">Child</font>, <font color="#008F00">C</font>.<font color="#008F00">SubSequence</font>.<font color="#008F00">Index</font> == <font color="#008F00">C</font>.<font color="#008F00">Index</font>, <font color="#008F00">C</font>.<font color="#008F00">SubSequence</font>.<font color="#008F00">Indices</font> : <font color="#008F00">Collection</font>, <font color="#008F00">C</font>.<font color="#008F00">SubSequence</font>.<font color="#008F00">SubSequence</font> == <font color="#008F00">C</font>.<font color="#008F00">SubSequence</font>, <font color="#008F00">C</font>.<font color="#008F00">Indices</font>.<font color="#008F00">Iterator</font>.<font color="#008F00">Element</font> == <font color="#008F00">C</font>.<font color="#008F00">Index</font>, <font color="#008F00">C</font>.<font color="#008F00">SubSequence</font>.<font color="#008F00">Indices</font>.<font color="#008F00">Index</font> == <font color="#008F00">C</font>.<font color="#008F00">Index</font>, <font color="#008F00">C</font>.<font color="#008F00">SubSequence</font>.<font color="#008F00">Indices</font>.<font color="#008F00">SubSequence</font> == <font color="#008F00">C</font>.<font color="#008F00">SubSequence</font>.<font color="#008F00">Indices</font>, <font color="#008F00">C</font>.<font color="#008F00">SubSequence</font>.<font color="#008F00">Iterator</font>.<font color="#008F00">Element</font> == <font color="#008F00">Mirror</font>.<font color="#008F00">Child</font>, <font color="#008F00">C</font>.<font color="#008F00">SubSequence</font>.<font color="#008F00">Indices</font>.<font color="#008F00">Iterator</font>.<font color="#008F00">Element</font> == <font color="#008F00">C</font>.<font color="#008F00">Index</font>>(_ subject: <font color="#008F00">Subject</font>, children: <font color="#008F00">C</font>, displayStyle: <font color="#008F00">Mirror</font>.<font color="#008F00">DisplayStyle</font>? = <font color="#941751">default</font>, ancestorRepresentation: <font color="#008F00">Mirror</font>.<font color="#008F00">AncestorRepresentation</font> = <font color="#941751">default</font>)</font></li></ul><div><font face="Menlo" color="#797979">/// ...</font></div></div><div><font face="Menlo">}</font></div></div><div><font face="Menlo"><br></font></div><div><span style="font-family:Menlo"><br></span></div><div><font color="#797979" face="Menlo">/// A collection that is its own sub-sequence</font></div><div><font face="Menlo"><font color="#941751">typealias</font><span class="m_7474794349195607222Apple-converted-space"> </span><font color="#008F00">RecursivelySliceableCollection</font><span class="m_7474794349195607222Apple-converted-space"> </span>=<span class="m_7474794349195607222Apple-converted-space"> </span><font color="#008F00">Collection</font><span class="m_7474794349195607222Apple-converted-space"> </span><font color="#941751">where</font></font></div><div><font color="#008F00" face="Menlo">RecursivelySliceableCollection</font><span style="font-family:Menlo">.</span><font color="#008F00" face="Menlo">SubSequence</font><font face="Menlo">:<span class="m_7474794349195607222Apple-converted-space"> </span><font color="#008F00">Collection</font>,</font></div><div><font color="#008F00" face="Menlo">RecursivelySliceableCollection</font><span style="font-family:Menlo">.</span><font color="#008F00" face="Menlo">SubSequence</font><span style="font-family:Menlo">.</span><font color="#008F00" face="Menlo">Element</font><span class="m_7474794349195607222Apple-converted-space"> </span><span style="font-family:Menlo">== </span><font color="#008F00" face="Menlo">RecursivelySliceableCollection</font><span style="font-family:Menlo">.</span><font color="#008F00" face="Menlo">Element</font></div><div><font color="#008F00" face="Menlo">RecursivelySliceableCollection</font><span style="font-family:Menlo">.</span><font color="#008F00" face="Menlo">SubSequence</font><span style="font-family:Menlo">.</span><font color="#008F00" face="Menlo">Indices</font><span class="m_7474794349195607222Apple-converted-space"> </span><span style="font-family:Menlo">== </span><font color="#008F00" face="Menlo">RecursivelySliceableCollection</font><span style="font-family:Menlo">.</span><font color="#008F00" face="Menlo">Indices</font><span style="font-family:Menlo">,</span></div><div><font color="#008F00" face="Menlo">RecursivelySliceableCollection</font><span style="font-family:Menlo">.</span><font color="#008F00" face="Menlo">SubSequence</font><span style="font-family:Menlo">.</span><font color="#008F00" face="Menlo">SubSequence</font><span class="m_7474794349195607222Apple-converted-space"> </span><span style="font-family:Menlo">== </span><font color="#008F00" face="Menlo">RecursivelySliceableCollection</font><span style="font-family:Menlo">.</span><font color="#008F00" face="Menlo">SubSequence</font></div><div><font face="Menlo"><br></font></div><div><font color="#797979" face="Menlo">/// A collection that is its own index collection</font></div><div><font color="#941751" face="Menlo">typealias</font><span class="m_7474794349195607222Apple-converted-space"> </span><font color="#008F00" face="Menlo">RecursivelyIndexableCollection</font><span class="m_7474794349195607222Apple-converted-space"> </span><span style="font-family:Menlo">=</span><span class="m_7474794349195607222Apple-converted-space"> </span><font color="#008F00" face="Menlo">Collection</font><span class="m_7474794349195607222Apple-converted-space"> </span><font color="#941751" face="Menlo">where</font></div><div><font color="#008F00" face="Menlo">RecursivelyIndexableCollection</font><span style="font-family:Menlo">.</span><font color="#008F00" face="Menlo">Indices</font><span class="m_7474794349195607222Apple-converted-space"> </span><span style="font-family:Menlo">== </span><font color="#008F00" face="Menlo">RecursivelySliceableCollection</font><span style="font-family:Menlo">,</span></div><div><font color="#008F00" face="Menlo">RecursivelyIndexableCollection</font><span style="font-family:Menlo">.</span><font color="#008F00" face="Menlo">Indices</font><span style="font-family:Menlo">.</span><font color="#008F00" face="Menlo">Index</font><span class="m_7474794349195607222Apple-converted-space"> </span><span style="font-family:Menlo">== </span><font color="#008F00" face="Menlo">RecursivelyIndexableCollection</font><span style="font-family:Menlo">.</span><font color="#008F00" face="Menlo">Index</font><span style="font-family:Menlo">,</span></div><div><span style="font-family:Menlo"><br></span></div><div><font color="#941751" face="Menlo">struct</font><span class="m_7474794349195607222Apple-converted-space"> </span><span style="font-family:Menlo">Mirror {</span></div><div><font color="#797979" face="Menlo">/// ...</font></div><div><font color="#941751" face="Menlo">init</font><span style="font-family:Menlo"><</span><font color="#008F00" face="Menlo">Subject</font><span style="font-family:Menlo">,</span><span class="m_7474794349195607222Apple-converted-space"> </span><font color="#008F00" face="Menlo">C</font><span style="font-family:Menlo">: </span><font color="#008F00" face="Menlo">RecursivelySliceableCollection</font><span class="m_7474794349195607222Apple-converted-space"> </span><span style="font-family:Menlo">& </span><font color="#008F00" face="Menlo">RecursivelyIndexableCollection</font><span style="font-family:Menlo">, </span><font color="#941751" face="Menlo">where</font> <font color="#008F00" face="Menlo">C</font><span style="font-family:Menlo">.</span><font color="#008F00" face="Menlo">Element</font><span class="m_7474794349195607222Apple-converted-space"> </span><span style="font-family:Menlo">==</span><span class="m_7474794349195607222Apple-converted-space"> </span><font color="#008F00" face="Menlo">Mirror</font><span style="font-family:Menlo">.</span><font color="#008F00" face="Menlo">Child</font><span style="font-family:Menlo">>(</span><span style="font-family:Menlo">_ subject:</span><span style="font-family:Menlo"> </span><font color="#008F00" style="font-family:Menlo">Subject</font><span style="font-family:Menlo">, children:</span><span style="font-family:Menlo"> </span><font color="#008F00" style="font-family:Menlo">C</font><span style="font-family:Menlo">, displayStyle:</span><span style="font-family:Menlo"> </span><font color="#008F00" style="font-family:Menlo">Mirror</font><span style="font-family:Menlo">.</span><font color="#008F00" style="font-family:Menlo">DisplayStyle</font><span style="font-family:Menlo">? =</span><span style="font-family:Menlo"> </span><font color="#941751" style="font-family:Menlo">default</font><span style="font-family:Menlo">, ancestorRepresentation:</span><span style="font-family:Menlo"> </span><font color="#008F00" style="font-family:Menlo">Mirror</font><span style="font-family:Menlo">.</span><font color="#008F00" style="font-family:Menlo">AncestorRepresentation</font><span style="font-family:Menlo"> </span><span style="font-family:Menlo">=</span><span style="font-family:Menlo"> </span><font color="#941751" style="font-family:Menlo">default</font><span style="font-family:Menlo">)</span></div><div><font color="#797979" face="Menlo">/// ...</font></div><div><span style="font-family:Menlo">}</span></div><div><br></div><div>Even considering that the proposal SE-0157 (<a href="https://github.com/apple/swift-evolution/blob/master/proposals/0157-recursive-protocol-constraints.md" style="color:rgb(65,131,196);background-color:inherit;text-decoration:none" target="_blank">https://github.com/apple/swift-evolution/blob/master/proposals/0157-recursive-protocol-constraints.md</a>) is going to make this specific use case a non-issue, the principle applies to all cases where there are commonly used complex constraints that don't necessarily involve recursive constraints.</div><div><br></div><div><b>Specializing Generic-Only Protocols For Non-Generic Use</b></div><div><br></div><div>An additional feature that would prove to be very useful would be to make a constrained protocol alias be a non-generic-only protocol if the constraints of the alias declaration specify a same-type requirement for all its associated types, while defaulted associated types would also count.</div><div>Example:</div><div><br></div><div><font face="Menlo"><font color="#941751">protocol</font><span class="m_7474794349195607222Apple-converted-space"> </span><font color="#008F00">Consumer</font><span class="m_7474794349195607222Apple-converted-space"> </span>{</font></div><div><font face="Menlo"><font color="#941751">associatedtype</font><span class="m_7474794349195607222Apple-converted-space"> </span><font color="#008F00">Consumable</font></font></div><div><font face="Menlo"><font color="#941751">mutating</font> <font color="#941751">func</font><span class="m_7474794349195607222Apple-converted-space"> </span>consume(_ consumable:<span class="m_7474794349195607222Apple-converted-space"> </span><font color="#008F00">Consumable</font>)<span class="m_7474794349195607222Apple-converted-space"> </span><font color="#941751">throws</font></font></div><div><font face="Menlo">}</font></div><div><font face="Menlo"><br></font></div><div><font face="Menlo"><font color="#941751">var</font><span class="m_7474794349195607222Apple-converted-space"> </span>consumer0:<span class="m_7474794349195607222Apple-converted-space"> </span><font color="#008F00">Consumer</font><span class="m_7474794349195607222Apple-converted-space"> </span><font color="#797979">// </font></font><span style="font-family:Menlo"><i><font color="#FF2600">error: Consumer is only usable in a generic context</font></i></span></div><div><font face="Menlo"><br></font></div><div><font face="Menlo"><font color="#941751">typealias</font><span class="m_7474794349195607222Apple-converted-space"> </span><font color="#008F00">CharacterConsumer</font><span class="m_7474794349195607222Apple-converted-space"> </span>=<span class="m_7474794349195607222Apple-converted-space"> </span><font color="#008F00">Consumer</font><span class="m_7474794349195607222Apple-converted-space"> </span><font color="#941751">where </font> </font><span style="color:rgb(0,143,0);font-family:Menlo">Character</span><font face="Menlo"><font color="#008F00">Consumer</font>.<font color="#008F00">Consumable</font><span class="m_7474794349195607222Apple-converted-space"> </span>== </font><span style="color:rgb(0,143,0);font-family:Menlo">Character</span></div><div><font face="Menlo"><br></font></div><div><font face="Menlo"><font color="#941751">var</font><span class="m_7474794349195607222Apple-converted-space"> </span>consumer1: </font><span style="color:rgb(0,143,0);font-family:Menlo">Character</span><font face="Menlo"><font color="#008F00">Consumer</font><span class="m_7474794349195607222Apple-converted-space"> </span><font color="#797979">// OK</font></font></div><div><br></div><div>The current workaround would be to declare a new protocol with protocol inheritance clauses and a<span class="m_7474794349195607222Apple-converted-space"> </span><font color="#941751" face="Menlo">where</font><span class="m_7474794349195607222Apple-converted-space"> </span>clause, but the major downside is that it introduces a completely new protocol that is not compatible with any context that expects the underlying protocols and their constraints.</div><div><br></div><div>Regards,</div><div>Gor Gyolchanyan.</div><div><br></div>_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" style="color:rgb(65,131,196);background-color:inherit;text-decoration:none" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="color:rgb(65,131,196);background-color:inherit;text-decoration:none" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></div></blockquote></div></blockquote></div><br></div></div></span></blockquote></div><div class="m_7474794349195607222bloop_markdown" style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254)"><br class="m_7474794349195607222Apple-interchange-newline"></div></div></blockquote></div></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" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div></div>