<html><head><style>
body {
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        padding:1em;
        margin:auto;
        background:#fefefe;
}
h1, h2, h3, h4, h5, h6 {
        font-weight: bold;
}
h1 {
        color: #000000;
        font-size: 28pt;
}
h2 {
        border-bottom: 1px solid #CCCCCC;
        color: #000000;
        font-size: 24px;
}
h3 {
        font-size: 18px;
}
h4 {
        font-size: 16px;
}
h5 {
        font-size: 14px;
}
h6 {
        color: #777777;
        background-color: inherit;
        font-size: 14px;
}
hr {
        height: 0.2em;
        border: 0;
        color: #CCCCCC;
        background-color: #CCCCCC;
display: inherit;
}
p, blockquote, ul, ol, dl, li, table, pre {
        margin: 15px 0;
}
a, a:visited {
        color: #4183C4;
        background-color: inherit;
        text-decoration: none;
}
#message {
        border-radius: 6px;
        border: 1px solid #ccc;
        display:block;
        width:100%;
        height:60px;
        margin:6px 0px;
}
button, #ws {
        font-size: 12 pt;
        padding: 4px 6px;
        border-radius: 5px;
        border: 1px solid #bbb;
        background-color: #eee;
}
code, pre, #ws, #message {
        font-family: Monaco;
        font-size: 10pt;
        border-radius: 3px;
        background-color: #F8F8F8;
        color: inherit;
}
code {
        border: 1px solid #EAEAEA;
        margin: 0 2px;
        padding: 0 5px;
}
pre {
        border: 1px solid #CCCCCC;
        overflow: auto;
        padding: 4px 8px;
}
pre > code {
        border: 0;
        margin: 0;
        padding: 0;
}
#ws { background-color: #f8f8f8; }
.bloop_markdown table {
border-collapse: collapse;
font-family: Helvetica, arial, freesans, clean, sans-serif;
color: rgb(51, 51, 51);
font-size: 15px; line-height: 25px;
padding: 0; }
.bloop_markdown table tr {
border-top: 1px solid #cccccc;
background-color: white;
margin: 0;
padding: 0; }
.bloop_markdown table tr:nth-child(2n) {
background-color: #f8f8f8; }
.bloop_markdown table tr th {
font-weight: bold;
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }
.bloop_markdown table tr td {
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }
.bloop_markdown table tr th :first-child, table tr td :first-child {
margin-top: 0; }
.bloop_markdown table tr th :last-child, table tr td :last-child {
margin-bottom: 0; }
.bloop_markdown blockquote{
border-left: 4px solid #dddddd;
padding: 0 15px;
color: #777777; }
blockquote > :first-child {
margin-top: 0; }
blockquote > :last-child {
margin-bottom: 0; }
code, pre, #ws, #message {
word-break: normal;
word-wrap: normal;
}
hr {
display: inherit;
}
.bloop_markdown :first-child {
-webkit-margin-before: 0;
}
code, pre, #ws, #message {
font-family: Menlo, Consolas, Liberation Mono, Courier, monospace;
}
.send { color:#77bb77; }
.server { color:#7799bb; }
.error { color:#AA0000; }</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="bloop_markdown"><p>Well I didn’t meant to say to spend time for something that will not even make into a review. If we can have some clarification from the core team, we still can decide if we’d tackle it or not. ;)</p>
<p></p></div><div class="bloop_original_html"><style>body{font-family:Helvetica,Arial;font-size:13px}</style><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div> <br> <div id="bloop_sign_1503329040343756800" class="bloop_sign"></div> <br><p class="airmail_on">Am 21. August 2017 um 14:51:06, David Hart (<a href="mailto:david@hartbit.com">david@hartbit.com</a>) schrieb:</p> <blockquote type="cite" class="clean_bq"><span><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div></div><div>
<title></title>
<br class="">
<div>
<blockquote type="cite" class="">
<div class="">On 21 Aug 2017, at 13:36, Adrian Zubarev <<a href="mailto:adrian.zubarev@devandartist.com" class="">adrian.zubarev@devandartist.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="bloop_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; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254);">
<p style="margin: 15px 0px; -webkit-margin-before: 0px;" class="">
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="Apple-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; -webkit-margin-before: 0px;" class="">where</code><span class="Apple-converted-space"> </span>clause support for
typealiases.<span class="Apple-converted-space"> </span></p>
<p style="margin: 15px 0px;" class="">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;" class="">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>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>
<blockquote type="cite" class="">
<div class="">
<div class="bloop_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; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254);">
<p style="margin: 15px 0px;" class="">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>
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.<br class="">
<blockquote type="cite" class="">
<div class="">
<div class="bloop_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; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254);">
<p style="margin: 15px 0px;" class="">It would be nice if someone
from the core team can clarify if the<span class="Apple-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; -webkit-margin-before: 0px;" class="">where</code><span class="Apple-converted-space"> </span>clause is out of scope for
Swift 5 or not.</p>
</div>
</div>
</blockquote>
<div>Agreed.</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div class="bloop_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; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254);">
<div id="bloop_sign_1503314850459755776" class="bloop_sign"></div>
<br class="">
<p class="airmail_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;" class="">david@hartbit.com</a>) schrieb:</p>
<blockquote type="cite" class="clean_bq" style="margin: 15px 0px;">
<div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div class=""></div>
<div class=""><span style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></span>
<div class="">
<blockquote type="cite" class="" style="margin: 15px 0px;">
<div class="" style="margin-top: 0px;"><span style="margin-top: 0px; margin-bottom: 0px;" class="">On 21 Aug 2017, at
11:41, Adrian Zubarev <<a href="mailto:adrian.zubarev@devandartist.com" class="" style="color: rgb(65, 131, 196); background-color: inherit; text-decoration: none;">adrian.zubarev@devandartist.com</a>>
wrote:</span></div>
<span style="margin-top: 0px; margin-bottom: 0px;" class=""><br class="Apple-interchange-newline"></span>
<div class="" style="margin-bottom: 0px;">
<div id="bloop_customfont" class="" 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; -webkit-text-stroke-width: 0px; margin: 0px;">
<span style="margin-top: 0px; margin-bottom: 0px;" class="">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)</span></div>
</div>
</blockquote>
<div class=""><span style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></span></div>
<div class=""><span style="margin-top: 0px; margin-bottom: 0px;" class="">Yes, this basically seems like<span class="Apple-converted-space"> </span><b class="">Generalized
Existentials</b><span class="Apple-converted-space"> </span>to
me and is mentioned in the <a href="https://github.com/apple/swift/blob/master/docs/GenericsManifesto.md" class="" style="color: rgb(65, 131, 196); background-color: inherit; text-decoration: none;">Generics
Manifesto</a>. It’s a feature I hold very dear but:</span></div>
<div class=""><br class=""></div>
<div class="">
<ul class="MailOutline" style="margin: 15px 0px;">
<li class="" 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 class="" 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 class=""><br class=""></div>
<div class="">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" class="" style="margin: 15px 0px;">
<div class="" style="margin-top: 0px; margin-bottom: 0px;">
<p class="airmail_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; -webkit-text-stroke-width: 0px;">
Am 21. August 2017 um 11:38:14, Gor Gyolchanyan via swift-evolution
(<a href="mailto:swift-evolution@swift.org" class="" style="color: rgb(65, 131, 196); background-color: inherit; text-decoration: none;">swift-evolution@swift.org</a>)
schrieb:</p>
<blockquote type="cite" class="clean_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; -webkit-text-stroke-width: 0px;">
<div class="" style="margin-top: 0px; margin-bottom: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div class=""></div>
<div class=""><span class="">Hello, Swift community!</span>
<div class=""><span class=""><br class=""></span></div>
<div class=""><span class="">I'd like to start a discussion about a
possibility of constrained protocol aliases. The declaration would
look like this:</span></div>
<div class=""><span class=""><br class=""></span></div>
<div class="">
<div class=""><span class=""><font face="Menlo" class=""><font color="#941751" class="">typealias</font><span class="Apple-converted-space"> </span><font color="#008F00" class="">BinaryProtocol</font><span class="Apple-converted-space"> </span>=<span class="Apple-converted-space"> </span><font color="#008F00" class="">RandomAccessCollection</font><span class="Apple-converted-space"> </span>&<span class="Apple-converted-space"> </span><font color="#008F00" class="">MutablCollection</font><span class="Apple-converted-space"> </span>&<span class="Apple-converted-space"> </span><font color="#008F00" class="">RangeReplaceableCollection</font><span class="Apple-converted-space"> </span><font color="#941751" class="">where</font> <font color="#008F00" class="">Binary</font>.<font color="#008F00" class="">Index</font><span class="Apple-converted-space"> </span>==<span class="Apple-converted-space"> </span><font color="#008F00" class="">Int</font>,<span class="Apple-converted-space"> </span><font color="#008F00" class="">Binary</font>.<font color="#008F00" class="">Element</font><span class="Apple-converted-space"> </span>==<span class="Apple-converted-space"> </span><font color="#008F00" class="">Bool</font></font></span></div>
</div>
<div class=""><br class=""></div>
<div class="">The syntax and semantics of this declaration are
exactly the same as an analogous<span class="Apple-converted-space"> </span><font color="#941751" face="Menlo" class="">associatedtype</font><span class="Apple-converted-space"> </span>declaration inside a
protocol.</div>
<div class="">In the example above, the type<span class="Apple-converted-space"> </span><font face="Menlo" color="#008F00" class="">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 class="">Now, it can be used in a very concise and elegant
way:</div>
<div class=""><br class=""></div>
<div class=""><font face="Menlo" class=""><font color="#941751" class="">public</font><span class="Apple-converted-space"> </span><font color="#941751" class="">protocol</font><span class="Apple-converted-space"> </span><font color="#008F00" class="">BinaryInitializable</font><span class="Apple-converted-space"> </span>{</font></div>
<div class=""><font face="Menlo" class=""><font color="#941751" class="">init</font><<font color="#008F00" class="">Binary</font>>(binary:<span class="Apple-converted-space"> </span><font color="#008F00" class="">Binary</font>)<span class="Apple-converted-space"> </span><font color="#941751" class="">where</font><span class="Apple-converted-space"> </span><font color="#008F00" class="">Binary</font>:<span class="Apple-converted-space"> </span><font color="#008F00" class="">BinaryProtocol</font></font></div>
<div class=""><font face="Menlo" class="">}</font></div>
<div class=""><br class=""></div>
<div class="">which would otherwise look very verbose and
inelegant:</div>
<div class=""><br class=""></div>
<div class=""><font face="Menlo" class=""><font color="#941751" class="">public</font><span class="Apple-converted-space"> </span><font color="#941751" class="">protocol</font><span class="Apple-converted-space"> </span><font color="#008F00" class="">BinaryInitializable</font><span class="Apple-converted-space"> </span>{</font></div>
<div class=""><font face="Menlo" class=""><font color="#941751" class="">init</font><<font color="#008F00" class="">Binary</font>>(binary:<span class="Apple-converted-space"> </span><font color="#008F00" class="">Binary</font>)<span class="Apple-converted-space"> </span><font color="#941751" class="">where</font><span class="Apple-converted-space"> </span>Binary: <font color="#008F00" class="">RandomAccessCollection</font> & <font color="#008F00" class="">MutablCollection</font> & <font color="#008F00" class="">RangeReplaceableCollection,</font> <font color="#008F00" class="">Binary</font>.<font color="#008F00" class="">Index</font> == <font color="#008F00" class="">Int</font>, <font color="#008F00" class="">Binary</font>.<font color="#008F00" class="">Element</font> == <font color="#008F00" class="">Bool</font></font></div>
<div class=""><font face="Menlo" class="">}</font></div>
<div class="">
<div class=""><br class=""></div>
<div class="">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 class=""><br class=""></div>
<div class=""><font face="Menlo" class=""><font color="#941751" class="">struct</font> <font color="#008F00" class="">Mirror</font> {</font></div>
<div class="">
<ul class="container" style="margin: 0px; box-sizing: border-box; padding: 0px; width: auto; list-style: none;">
<li class="" style="margin: 15px 0px;"><font face="Menlo" class=""><font color="#797979" class="">/// ...</font></font></li>
<li class="" style="margin: 15px 0px;"><font face="Menlo" class=""><font color="#941751" class="">init</font><<font color="#008F00" class="">Subject</font>, <font color="#008F00" class="">C</font> <font color="#941751" class="">where</font> <font color="#008F00" class="">C</font> : <font color="#008F00" class="">Collection</font>, <font color="#008F00" class="">C</font>.<font color="#008F00" class="">Indices</font> : <font color="#008F00" class="">Collection</font>, <font color="#008F00" class="">C</font>.<font color="#008F00" class="">SubSequence</font> : <font color="#008F00" class="">Collection</font>, <font color="#008F00" class="">C</font>.<font color="#008F00" class="">Indices</font>.<font color="#008F00" class="">Index</font> == <font color="#008F00" class="">C</font>.<font color="#008F00" class="">Index</font>, <font color="#008F00" class="">C</font>.<font color="#008F00" class="">Indices</font>.<font color="#008F00" class="">SubSequence</font> == <font color="#008F00" class="">C</font>.<font color="#008F00" class="">Indices</font>, <font color="#008F00" class="">C</font>.<font color="#008F00" class="">Iterator</font>.<font color="#008F00" class="">Element</font> == <font color="#008F00" class="">Mirror</font>.<font color="#008F00" class="">Child</font>, <font color="#008F00" class="">C</font>.<font color="#008F00" class="">SubSequence</font>.<font color="#008F00" class="">Index</font> == <font color="#008F00" class="">C</font>.<font color="#008F00" class="">Index</font>, <font color="#008F00" class="">C</font>.<font color="#008F00" class="">SubSequence</font>.<font color="#008F00" class="">Indices</font> : <font color="#008F00" class="">Collection</font>, <font color="#008F00" class="">C</font>.<font color="#008F00" class="">SubSequence</font>.<font color="#008F00" class="">SubSequence</font> == <font color="#008F00" class="">C</font>.<font color="#008F00" class="">SubSequence</font>, <font color="#008F00" class="">C</font>.<font color="#008F00" class="">Indices</font>.<font color="#008F00" class="">Iterator</font>.<font color="#008F00" class="">Element</font> == <font color="#008F00" class="">C</font>.<font color="#008F00" class="">Index</font>, <font color="#008F00" class="">C</font>.<font color="#008F00" class="">SubSequence</font>.<font color="#008F00" class="">Indices</font>.<font color="#008F00" class="">Index</font> == <font color="#008F00" class="">C</font>.<font color="#008F00" class="">Index</font>, <font color="#008F00" class="">C</font>.<font color="#008F00" class="">SubSequence</font>.<font color="#008F00" class="">Indices</font>.<font color="#008F00" class="">SubSequence</font> == <font color="#008F00" class="">C</font>.<font color="#008F00" class="">SubSequence</font>.<font color="#008F00" class="">Indices</font>, <font color="#008F00" class="">C</font>.<font color="#008F00" class="">SubSequence</font>.<font color="#008F00" class="">Iterator</font>.<font color="#008F00" class="">Element</font> == <font color="#008F00" class="">Mirror</font>.<font color="#008F00" class="">Child</font>, <font color="#008F00" class="">C</font>.<font color="#008F00" class="">SubSequence</font>.<font color="#008F00" class="">Indices</font>.<font color="#008F00" class="">Iterator</font>.<font color="#008F00" class="">Element</font> == <font color="#008F00" class="">C</font>.<font color="#008F00" class="">Index</font>>(_
subject: <font color="#008F00" class="">Subject</font>,
children: <font color="#008F00" class="">C</font>,
displayStyle: <font color="#008F00" class="">Mirror</font>.<font color="#008F00" class="">DisplayStyle</font>? = <font color="#941751" class="">default</font>, ancestorRepresentation: <font color="#008F00" class="">Mirror</font>.<font color="#008F00" class="">AncestorRepresentation</font> = <font color="#941751" class="">default</font>)</font></li>
</ul>
<div class=""><font face="Menlo" color="#797979" class="">///
...</font></div>
</div>
<div class=""><font face="Menlo" class="">}</font></div>
</div>
<div class=""><font face="Menlo" class=""><br class=""></font></div>
<div class=""><span class="" style="font-family: Menlo;"><br class=""></span></div>
<div class=""><font color="#797979" face="Menlo" class="">/// A
collection that is its own sub-sequence</font></div>
<div class=""><font face="Menlo" class=""><font color="#941751" class="">typealias</font><span class="Apple-converted-space"> </span><font color="#008F00" class="">RecursivelySliceableCollection</font><span class="Apple-converted-space"> </span>=<span class="Apple-converted-space"> </span><font color="#008F00" class="">Collection</font><span class="Apple-converted-space"> </span><font color="#941751" class="">where</font></font></div>
<div class=""><font color="#008F00" face="Menlo" class="">RecursivelySliceableCollection</font><span class="" style="font-family: Menlo;">.</span><font color="#008F00" face="Menlo" class="">SubSequence</font><font face="Menlo" class="">:<span class="Apple-converted-space"> </span><font color="#008F00" class="">Collection</font>,</font></div>
<div class=""><font color="#008F00" face="Menlo" class="">RecursivelySliceableCollection</font><span class="" style="font-family: Menlo;">.</span><font color="#008F00" face="Menlo" class="">SubSequence</font><span class="" style="font-family: Menlo;">.</span><font color="#008F00" face="Menlo" class="">Element</font><span class="Apple-converted-space"> </span><span class="" style="font-family: Menlo;">== </span><font color="#008F00" face="Menlo" class="">RecursivelySliceableCollection</font><span class="" style="font-family: Menlo;">.</span><font color="#008F00" face="Menlo" class="">Element</font></div>
<div class=""><font color="#008F00" face="Menlo" class="">RecursivelySliceableCollection</font><span class="" style="font-family: Menlo;">.</span><font color="#008F00" face="Menlo" class="">SubSequence</font><span class="" style="font-family: Menlo;">.</span><font color="#008F00" face="Menlo" class="">Indices</font><span class="Apple-converted-space"> </span><span class="" style="font-family: Menlo;">== </span><font color="#008F00" face="Menlo" class="">RecursivelySliceableCollection</font><span class="" style="font-family: Menlo;">.</span><font color="#008F00" face="Menlo" class="">Indices</font><span class="" style="font-family: Menlo;">,</span></div>
<div class=""><font color="#008F00" face="Menlo" class="">RecursivelySliceableCollection</font><span class="" style="font-family: Menlo;">.</span><font color="#008F00" face="Menlo" class="">SubSequence</font><span class="" style="font-family: Menlo;">.</span><font color="#008F00" face="Menlo" class="">SubSequence</font><span class="Apple-converted-space"> </span><span class="" style="font-family: Menlo;">== </span><font color="#008F00" face="Menlo" class="">RecursivelySliceableCollection</font><span class="" style="font-family: Menlo;">.</span><font color="#008F00" face="Menlo" class="">SubSequence</font></div>
<div class=""><font face="Menlo" class=""><br class=""></font></div>
<div class=""><font color="#797979" face="Menlo" class="">/// A
collection that is its own index collection</font></div>
<div class=""><font color="#941751" face="Menlo" class="">typealias</font><span class="Apple-converted-space"> </span><font color="#008F00" face="Menlo" class="">RecursivelyIndexableCollection</font><span class="Apple-converted-space"> </span><span class="" style="font-family: Menlo;">=</span><span class="Apple-converted-space"> </span><font color="#008F00" face="Menlo" class="">Collection</font><span class="Apple-converted-space"> </span><font color="#941751" face="Menlo" class="">where</font></div>
<div class=""><font color="#008F00" face="Menlo" class="">RecursivelyIndexableCollection</font><span class="" style="font-family: Menlo;">.</span><font color="#008F00" face="Menlo" class="">Indices</font><span class="Apple-converted-space"> </span><span class="" style="font-family: Menlo;">== </span><font color="#008F00" face="Menlo" class="">RecursivelySliceableCollection</font><span class="" style="font-family: Menlo;">,</span></div>
<div class=""><font color="#008F00" face="Menlo" class="">RecursivelyIndexableCollection</font><span class="" style="font-family: Menlo;">.</span><font color="#008F00" face="Menlo" class="">Indices</font><span class="" style="font-family: Menlo;">.</span><font color="#008F00" face="Menlo" class="">Index</font><span class="Apple-converted-space"> </span><span class="" style="font-family: Menlo;">== </span><font color="#008F00" face="Menlo" class="">RecursivelyIndexableCollection</font><span class="" style="font-family: Menlo;">.</span><font color="#008F00" face="Menlo" class="">Index</font><span class="" style="font-family: Menlo;">,</span></div>
<div class=""><span class="" style="font-family: Menlo;"><br class=""></span></div>
<div class=""><font color="#941751" face="Menlo" class="">struct</font><span class="Apple-converted-space"> </span><span class="" style="font-family: Menlo;">Mirror {</span></div>
<div class=""><font color="#797979" face="Menlo" class="">///
...</font></div>
<div class=""><font color="#941751" face="Menlo" class="">init</font><span class="" style="font-family: Menlo;"><</span><font color="#008F00" face="Menlo" class="">Subject</font><span class="" style="font-family: Menlo;">,</span><span class="Apple-converted-space"> </span><font color="#008F00" face="Menlo" class="">C</font><span class="" style="font-family: Menlo;">: </span><font color="#008F00" face="Menlo" class="">RecursivelySliceableCollection</font><span class="Apple-converted-space"> </span><span class="" style="font-family: Menlo;">& </span><font color="#008F00" face="Menlo" class="">RecursivelyIndexableCollection</font><span class="" style="font-family: Menlo;">, </span><font color="#941751" face="Menlo" class="">where</font> <font color="#008F00" face="Menlo" class="">C</font><span class="" style="font-family: Menlo;">.</span><font color="#008F00" face="Menlo" class="">Element</font><span class="Apple-converted-space"> </span><span class="" style="font-family: Menlo;">==</span><span class="Apple-converted-space"> </span><font color="#008F00" face="Menlo" class="">Mirror</font><span class="" style="font-family: Menlo;">.</span><font color="#008F00" face="Menlo" class="">Child</font><span class="" style="font-family: Menlo;">>(</span><span class="" style="font-family: Menlo;">_ subject:</span><span class="" style="font-family: Menlo;"> </span><font color="#008F00" class="" style="font-family: Menlo;">Subject</font><span class="" style="font-family: Menlo;">, children:</span><span class="" style="font-family: Menlo;"> </span><font color="#008F00" class="" style="font-family: Menlo;">C</font><span class="" style="font-family: Menlo;">, displayStyle:</span><span class="" style="font-family: Menlo;"> </span><font color="#008F00" class="" style="font-family: Menlo;">Mirror</font><span class="" style="font-family: Menlo;">.</span><font color="#008F00" class="" style="font-family: Menlo;">DisplayStyle</font><span class="" style="font-family: Menlo;">? =</span><span class="" style="font-family: Menlo;"> </span><font color="#941751" class="" style="font-family: Menlo;">default</font><span class="" style="font-family: Menlo;">, ancestorRepresentation:</span><span class="" style="font-family: Menlo;"> </span><font color="#008F00" class="" style="font-family: Menlo;">Mirror</font><span class="" style="font-family: Menlo;">.</span><font color="#008F00" class="" style="font-family: Menlo;">AncestorRepresentation</font><span class="" style="font-family: Menlo;"> </span><span class="" style="font-family: Menlo;">=</span><span class="" style="font-family: Menlo;"> </span><font color="#941751" class="" style="font-family: Menlo;">default</font><span class="" style="font-family: Menlo;">)</span></div>
<div class=""><font color="#797979" face="Menlo" class="">///
...</font></div>
<div class=""><span class="" style="font-family: Menlo;">}</span></div>
<div class=""><br class=""></div>
<div class="">Even considering that the proposal SE-0157 (<a href="https://github.com/apple/swift-evolution/blob/master/proposals/0157-recursive-protocol-constraints.md" class="" style="color: rgb(65, 131, 196); background-color: inherit; text-decoration: none;">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 class=""><br class=""></div>
<div class=""><b class="">Specializing Generic-Only Protocols For
Non-Generic Use</b></div>
<div class=""><br class=""></div>
<div class="">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 class="">Example:</div>
<div class=""><br class=""></div>
<div class=""><font face="Menlo" class=""><font color="#941751" class="">protocol</font><span class="Apple-converted-space"> </span><font color="#008F00" class="">Consumer</font><span class="Apple-converted-space"> </span>{</font></div>
<div class=""><font face="Menlo" class=""><font color="#941751" class="">associatedtype</font><span class="Apple-converted-space"> </span><font color="#008F00" class="">Consumable</font></font></div>
<div class=""><font face="Menlo" class=""><font color="#941751" class="">mutating</font> <font color="#941751" class="">func</font><span class="Apple-converted-space"> </span>consume(_
consumable:<span class="Apple-converted-space"> </span><font color="#008F00" class="">Consumable</font>)<span class="Apple-converted-space"> </span><font color="#941751" class="">throws</font></font></div>
<div class=""><font face="Menlo" class="">}</font></div>
<div class=""><font face="Menlo" class=""><br class=""></font></div>
<div class=""><font face="Menlo" class=""><font color="#941751" class="">var</font><span class="Apple-converted-space"> </span>consumer0:<span class="Apple-converted-space"> </span><font color="#008F00" class="">Consumer</font><span class="Apple-converted-space"> </span><font color="#797979" class="">// </font></font><span class="" style="font-family: Menlo;"><i class=""><font color="#FF2600" class="">error: Consumer is only usable in a generic
context</font></i></span></div>
<div class=""><font face="Menlo" class=""><br class=""></font></div>
<div class=""><font face="Menlo" class=""><font color="#941751" class="">typealias</font><span class="Apple-converted-space"> </span><font color="#008F00" class="">CharacterConsumer</font><span class="Apple-converted-space"> </span>=<span class="Apple-converted-space"> </span><font color="#008F00" class="">Consumer</font><span class="Apple-converted-space"> </span><font color="#941751" class="">where </font> </font><span class="" style="color: rgb(0, 143, 0); font-family: Menlo;">Character</span><font face="Menlo" class=""><font color="#008F00" class="">Consumer</font>.<font color="#008F00" class="">Consumable</font><span class="Apple-converted-space"> </span>== </font><span class="" style="color: rgb(0, 143, 0); font-family: Menlo;">Character</span></div>
<div class=""><font face="Menlo" class=""><br class=""></font></div>
<div class=""><font face="Menlo" class=""><font color="#941751" class="">var</font><span class="Apple-converted-space"> </span>consumer1: </font><span class="" style="color: rgb(0, 143, 0); font-family: Menlo;">Character</span><font face="Menlo" class=""><font color="#008F00" class="">Consumer</font><span class="Apple-converted-space"> </span><font color="#797979" class="">// OK</font></font></div>
<div class=""><br class=""></div>
<div class="">The current workaround would be to declare a new
protocol with protocol inheritance clauses and a<span class="Apple-converted-space"> </span><font color="#941751" face="Menlo" class="">where</font><span class="Apple-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 class=""><br class=""></div>
<div class="">Regards,</div>
<div class="">Gor Gyolchanyan.</div>
<div class=""><br class=""></div>
_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" class="" style="color: rgb(65, 131, 196); background-color: inherit; text-decoration: none;">
swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="" style="color: rgb(65, 131, 196); background-color: inherit; text-decoration: none;">
https://lists.swift.org/mailman/listinfo/swift-evolution</a></div>
</div>
</blockquote>
</div>
</blockquote>
</div>
<br class=""></div>
</div>
</blockquote>
</div>
<div class="bloop_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; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254);">
<br class="Apple-interchange-newline"></div>
</div>
</blockquote>
</div>
<br class="">
</div></div></span></blockquote></div><div class="bloop_markdown"><p></p></div></body></html>