<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 6, 2017, at 11:12 PM, Karl Wagner via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 7 Feb 2017, at 06:05, Slava Pestov &lt;<a href="mailto:spestov@apple.com" class="">spestov@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"><div class=""><br class="Apple-interchange-newline">On Feb 6, 2017, at 9:00 PM, Karl Wagner via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><pre class="" style="word-wrap: break-word; white-space: pre-wrap;">- Nested protocols in generic types are not parameterised by the parent's generic parameters.</pre></div></div></blockquote><div style="font-family: Helvetica; font-size: 12px; 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;" class="">So if I write GenericType&lt;Int&gt;.SomeProto and GenericType&lt;String&gt;.SomeProto, is it the same protocol? What about GenericType.SomeProto, is that allowed?</div><div style="font-family: Helvetica; font-size: 12px; 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;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; 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;" class="">Slava</div></div></blockquote></div><br class=""><div class="">GenericType.SomeProto (without parameters) is the only spelling that is allowed. There is no GenericType&lt;Int&gt;.SomeProto.</div><div class=""><br class=""></div><div class="">That way we avoid every bound-generic type creating a new protocol.&nbsp;</div></div></div></blockquote><div><br class=""></div><div>I have only had a chance to scan the proposal so I will probably have more comments after I take a closer look, but I want to respond to this topic right away.</div><div><br class=""></div><div>I understand the reason why you want it to work this way, but think it will be a significant source of confusion. &nbsp;Protocols will behave differently than any other entity nested in a generic type. &nbsp;This means the protocols nested in generic types will likely be counterintuitive for most people. &nbsp;</div><div><br class=""></div><div>I know this was the case for me while I was scanning the proposal. &nbsp;I had to think carefully to understand how you want this to work and why you want this behavior. &nbsp;That is despite it being a relatively direct consequence of the Swift’s design for protocols, which uses associated types and intentionally does not allow generic protocols.</div><div><br class=""></div><div>It may be that there isn’t a good way to avoid that and we need to try to address it through documentation and education. &nbsp;But I think this should receive careful consideration before we commit to this direction.</div><div><br class=""></div><div>Overall the proposal looks really great! &nbsp;I’m really looking forward to this feature. &nbsp;</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I think it works really nicely when you consider what it would like like with existential-based capturing. Notice that there is only one ‘MyCollectionView.Source’, and compatibility is determined based on existential constraints.</div><div class=""><br class=""></div><div class="">- Karl</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><pre style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; background-color: rgb(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal; color: rgb(51, 51, 51);" class=""><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">class</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">MyCollectionView</span>&lt;<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">MediaItem</span>&gt; : <span class="pl-e" style="box-sizing: border-box; color: rgb(121, 93, 163);">UICollectionView </span>{

    <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">protocol</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">Source</span> {
        <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="pl-c" style="box-sizing: border-box;">//</span> [implicit] associatedtype MediaItem</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span>        <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">item</span>(<span class="pl-smi" style="box-sizing: border-box;"><span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">at</span></span>: <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Int</span>) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-&gt;</span> MediaItem
        <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">var</span> numberOfItems<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">:</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Int</span> { <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">get</span> }
    }
    <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">var</span> source<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">:</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Any</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&lt;</span>MyCollectionView.<span class="pl-smi" style="box-sizing: border-box;">Source</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">where</span> .<span class="pl-smi" style="box-sizing: border-box;">MediaItem</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">==</span> MediaItem<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&gt;</span> <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="pl-c" style="box-sizing: border-box;">//</span> Not possible today.</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span>}

<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">class</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">BookSource</span>: <span class="pl-e" style="box-sizing: border-box; color: rgb(121, 93, 163);">MyCollectionView</span>.<span class="pl-e" style="box-sizing: border-box; color: rgb(121, 93, 163);">Source </span>{
    <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">typealias</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">MediaItem</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> Book

    <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">item</span>(<span class="pl-smi" style="box-sizing: border-box;"><span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">at</span></span>: <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Int</span>) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-&gt;</span> Book { <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="pl-c" style="box-sizing: border-box;">/*</span> ... <span class="pl-c" style="box-sizing: border-box;">*/</span></span> }
    <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">var</span> numberOfItems<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">:</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Int</span>     { <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="pl-c" style="box-sizing: border-box;">/*</span> ... <span class="pl-c" style="box-sizing: border-box;">*/</span></span> }
}

<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">class</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">DummySource</span>&lt;<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">MediaItem</span>&gt;: <span class="pl-e" style="box-sizing: border-box; color: rgb(121, 93, 163);">MyCollectionView</span>.<span class="pl-e" style="box-sizing: border-box; color: rgb(121, 93, 163);">Source </span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">where</span> MediaItem<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">:</span> <span class="pl-e" style="box-sizing: border-box; color: rgb(121, 93, 163);">DummyConstructable</span> {
    <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="pl-c" style="box-sizing: border-box;">//</span> associatedtype 'MediaItem' bound to generic parameter.</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span>
    <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">item</span>(<span class="pl-smi" style="box-sizing: border-box;"><span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">at</span></span>: <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Int</span>) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-&gt;</span> MediaItem { <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="pl-c" style="box-sizing: border-box;">/*</span> ... <span class="pl-c" style="box-sizing: border-box;">*/</span></span> }
    <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">var</span> numberOfItems<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">:</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Int</span>          { <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="pl-c" style="box-sizing: border-box;">/*</span> ... <span class="pl-c" style="box-sizing: border-box;">*/</span></span> } 
}

MyCollectionView<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&lt;</span>Book<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&gt;</span>().<span class="pl-smi" style="box-sizing: border-box;">source</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">BookSource</span>()
MyCollectionView<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&lt;</span>Book<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&gt;</span>().<span class="pl-smi" style="box-sizing: border-box;">source</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> DummySource<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&lt;</span>Book<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&gt;</span>()
MyCollectionView<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&lt;</span>Song<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&gt;</span>().<span class="pl-smi" style="box-sizing: border-box;">source</span>  <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">DummySource</span>() <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="pl-c" style="box-sizing: border-box;">//</span> type is: DummySource&lt;Song&gt;</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span>MyCollectionView<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&lt;</span>Movie<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&gt;</span>().<span class="pl-smi" style="box-sizing: border-box;">source</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">DummySource</span>() <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="pl-c" style="box-sizing: border-box;">//</span> type is: DummySource&lt;Movie&gt;</span></pre><div class=""><br class=""></div></div><div class=""><br class=""></div><div class=""><br class=""></div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>