<div dir="ltr">On Sat, Dec 3, 2016 at 12:02 PM, Daniel Leping via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">@Adrian, my comments inline below. Hope this helps.<br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Sat, Dec 3, 2016 at 6:22 PM, Adrian Zubarev <span dir="ltr"><<a href="mailto:adrian.zubarev@devandartist.com" target="_blank">adrian.zubarev@devandartist.<wbr>com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div class="m_-6431036212696460543gmail-m_805315748064065134bloop_markdown"><p>There is one thing that I want to point out with pitched syntactic sugar. <code>GenericMyProtocolName<U></code> will also let you reuse <code>T</code> within a generic type, where currently we cannot nest protocols into types. Even if we could, it’s not clear if nested declarations like <code>protocol MyTProtocolName : MyProtocolName where U == T</code> would be possible, so that <code>T</code> from the outer generic type is accessible. </p>
<p>Autogenerating the only possible generic protocols from protocols with associated types as a syntactic sugar to reduce spawning of types like <code>IntFoo</code> (as previously showed) seems reasonable to me. It does not break the current protocol system, but solves the first generic protocol feature from the generics manifesto.</p>
<p>There are still a few more questioned to answer:</p>
<ul>
<li>How dow we want the generated parameter list to look like?</li></ul></div></div></blockquote></span><div> The most obvious thing is to do something like Foo<Alias1 = Int, Alias2 = String>. Otherwise we'll have to add some sort of associatedtype sorting before; which doesn't sound good and just adds more complexity. Any other options?</div><span class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div class="m_-6431036212696460543gmail-m_805315748064065134bloop_markdown"><ul>
<li>Can we drop <code>Generic</code> prefix without collisions?</li></ul></div></div></blockquote></span><div>I'm pretty sure we could just use existing protocols. All the namings can be compiler generated as a function from protocol and arguments.</div><span class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div class="m_-6431036212696460543gmail-m_805315748064065134bloop_markdown"><ul>
<li>Does this syntactic sugar improves the stdlib or affect ABI?</li></ul></div></div></blockquote></span><div>Don't see any implications. Assuming current stdlib doesn't use the feature. It's rather an addition than change.</div><span class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div class="m_-6431036212696460543gmail-m_805315748064065134bloop_markdown"><ul>
</ul>
<p>There are probably some more questions I cannot foresee by myself. Feel free to jump in the discussion. ;)</p>
<p>PS: Yes this syntactic sugar does create an alternative way of creating ‘kinda’ the same protocol twice, but it reuses the pattern more naturally.</p>
<pre><code class="m_-6431036212696460543gmail-m_805315748064065134swift">protocol Foo { associatetype Inner : SomeOtherProtocol }
// Assuming String and Int conforms to SomeOtherProtocol
protocol StringFoo : Foo where Inner == String {}
protocol IntFoo : Foo where Inner == Int {}</code></pre></div></div></blockquote></span></div></div></div></blockquote><div><br></div><div>I thought I understood the initial topic of discussion, but I am lost here. What is unsatisfactory about the code you wrote above and why do we need new sugar for it?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div class="m_-6431036212696460543gmail-m_805315748064065134bloop_markdown"><pre><code class="m_-6431036212696460543gmail-m_805315748064065134swift">// VS.
// autogenerated
procotol GenericFoo<Inner : SomeOtherProtocol> : Foo { … }
// usage
GenericFoo<String>
GenericFoo<Int>
// or
typealias StringFoo = GenericFoo<String>
typealias IntFoo = GenericFoo<Int></code></pre></div></div></blockquote></span><div>// The usage I propose is just do</div><div>typealias StringFoo = Foo<Inner = String></div><div><br></div><div>//also in an inheritance like this:</div><div>class FooClass : Foo<Inner = String>, Foo<Inner = Int> {</div><div>//My question here is, though: how do we access Inner from FooClass<br></div><div><br></div><div>//Like this?</div><div>typealias InnerInt = Foo<Inner = String>.Inner</div><span class=""><div>}</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div class="m_-6431036212696460543gmail-m_805315748064065134bloop_markdown"><pre> </pre></div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div class="m_-6431036212696460543gmail-m_805315748064065134bloop_markdown"><pre><code class="m_-6431036212696460543gmail-m_805315748064065134swift">
</code></pre>
<p></p></div><div class="m_-6431036212696460543gmail-m_805315748064065134bloop_original_html"><span class="m_-6431036212696460543gmail-"><div id="m_-6431036212696460543gmail-m_805315748064065134bloop_customfont" style="font-family:helvetica,arial;font-size:13px;color:rgb(0,0,0);margin:0px"><br></div> <br> <div id="m_-6431036212696460543gmail-m_805315748064065134bloop_sign_1480780772434896896" class="m_-6431036212696460543gmail-m_805315748064065134bloop_sign"><div style="font-family:helvetica,arial;font-size:13px">-- <br>Adrian Zubarev<br>Sent with Airmail</div></div> <br></span><div><div class="m_-6431036212696460543gmail-h5"><p class="m_-6431036212696460543gmail-m_805315748064065134airmail_on">Am 3. Dezember 2016 um 16:43:43, Daniel Leping (<a href="mailto:daniel@crossroadlabs.xyz" target="_blank">daniel@crossroadlabs.xyz</a>) schrieb:</p> <blockquote type="cite" class="m_-6431036212696460543gmail-m_805315748064065134clean_bq"><span><div><div></div><div>
<div style="white-space:pre-wrap">In general I'm very positive with
the idea of generic protocols. This discussion is more about
syntactic sugar, though I really like where it goes.<br>
<br>
Off topic:<br>
IMO, we should revisit approaches others already use for conflicts
resolution. I personally tend to get something similar to Scala
traits. Should fit POT smoothly and naturally.</div>
<br>
<div class="gmail_quote">
<div dir="ltr">On Sat, 3 Dec 2016 at 16:30 Adrian Zubarev
<<a href="mailto:adrian.zubarev@devandartist.com" target="_blank">adrian.zubarev@devandartist.c<wbr>om</a>>
wrote:<br></div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div style="word-wrap:break-word" class="m_-6431036212696460543gmail-m_805315748064065134gmail_msg">
<div class="m_-6431036212696460543gmail-m_805315748064065134m_6921161786416199282bloop_markdown m_-6431036212696460543gmail-m_805315748064065134gmail_msg">
<p class="m_-6431036212696460543gmail-m_805315748064065134gmail_msg">If I’m not mistaken here, <code class="m_-6431036212696460543gmail-m_805315748064065134gmail_msg">extension Foo where T == Int</code> will have an error
of redeclaration <code class="m_-6431036212696460543gmail-m_805315748064065134gmail_msg">foo</code> anyways.</p>
<p class="m_-6431036212696460543gmail-m_805315748064065134gmail_msg"></p>
</div>
<div class="m_-6431036212696460543gmail-m_805315748064065134m_6921161786416199282bloop_original_html m_-6431036212696460543gmail-m_805315748064065134gmail_msg">
</div>
</div>
<div style="word-wrap:break-word" class="m_-6431036212696460543gmail-m_805315748064065134gmail_msg">
<div class="m_-6431036212696460543gmail-m_805315748064065134m_6921161786416199282bloop_original_html m_-6431036212696460543gmail-m_805315748064065134gmail_msg">
<div id="m_-6431036212696460543gmail-m_805315748064065134m_6921161786416199282bloop_customfont" style="font-family:helvetica,arial;font-size:13px;color:rgb(0,0,0);margin:0px" class="m_-6431036212696460543gmail-m_805315748064065134gmail_msg"><br class="m_-6431036212696460543gmail-m_805315748064065134gmail_msg"></div>
<div id="m_-6431036212696460543gmail-m_805315748064065134m_6921161786416199282bloop_sign_1480775153794472960" class="m_-6431036212696460543gmail-m_805315748064065134m_6921161786416199282bloop_sign m_-6431036212696460543gmail-m_805315748064065134gmail_msg">
<div style="font-family:helvetica,arial;font-size:13px" class="m_-6431036212696460543gmail-m_805315748064065134gmail_msg">-- <br class="m_-6431036212696460543gmail-m_805315748064065134gmail_msg">
Adrian Zubarev<br class="m_-6431036212696460543gmail-m_805315748064065134gmail_msg">
Sent with Airmail</div>
</div>
<br class="m_-6431036212696460543gmail-m_805315748064065134gmail_msg"></div>
</div>
<div style="word-wrap:break-word" class="m_-6431036212696460543gmail-m_805315748064065134gmail_msg">
<div class="m_-6431036212696460543gmail-m_805315748064065134m_6921161786416199282bloop_original_html m_-6431036212696460543gmail-m_805315748064065134gmail_msg">
<p class="m_-6431036212696460543gmail-m_805315748064065134m_6921161786416199282airmail_on m_-6431036212696460543gmail-m_805315748064065134gmail_msg">Am 3. Dezember
2016 um 15:22:56, Adrian Zubarev (<a href="mailto:adrian.zubarev@devandartist.com" class="m_-6431036212696460543gmail-m_805315748064065134gmail_msg" target="_blank">adrian.zubarev@devandartist.c<wbr>om</a>) schrieb:</p>
<blockquote type="cite" class="m_-6431036212696460543gmail-m_805315748064065134m_6921161786416199282clean_bq m_-6431036212696460543gmail-m_805315748064065134gmail_msg">
<div class="m_-6431036212696460543gmail-m_805315748064065134gmail_msg">
<pre style="margin:15px 0px;font-family:menlo,consolas,"liberation mono",courier,monospace;font-size:10pt;border-radius:3px;background-color:rgb(248,248,248);color:rgb(0,0,0);border:1px solid rgb(204,204,204);overflow:auto;padding:4px 8px;word-break:normal;word-wrap:normal;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;word-spacing:0px" class="m_-6431036212696460543gmail-m_805315748064065134gmail_msg"><span class="m_-6431036212696460543gmail-m_805315748064065134gmail_msg"><code class="m_-6431036212696460543gmail-m_805315748064065134m_6921161786416199282swift m_-6431036212696460543gmail-m_805315748064065134gmail_msg" style="font-family:menlo,consolas,"liberation mono",courier,monospace;font-size:10pt;border-radius:3px;background-color:rgb(248,248,248);color:inherit;border:0px;margin:0px;padding:0px;word-break:normal;word-wrap:normal">extension Foo where T == Int {
func foo() {
self.bar(o: 42) // calls a function that accepts an Int
}
}</code></span></pre></div>
</blockquote>
</div>
</div>
</blockquote>
</div>
</div></div></span></blockquote></div></div></div><div class="m_-6431036212696460543gmail-m_805315748064065134bloop_markdown"><p></p></div></div></blockquote></span></div><br></div></div>
<br>______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
<br></blockquote></div><br></div></div>