protocol Foo { associatetype Inner : SomeOtherProtocol }<br><br>// Assuming String and Int conforms to SomeOtherProtocol<br>protocol StringFoo : Foo where Inner == String {} <br>protocol IntFoo : Foo where Inner == Int {}<br><div class="gmail_quote"><div dir="ltr">On Sat, Dec 3, 2016 at 13:57 Adrian Zubarev <<a href="mailto:adrian.zubarev@devandartist.com">adrian.zubarev@devandartist.com</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" class="gmail_msg"><div class="m_1455031498856370709bloop_markdown gmail_msg"><p class="gmail_msg">To which code ‘above’ do you refer exactly?</p>
<p class="gmail_msg"></p></div><div class="m_1455031498856370709bloop_original_html gmail_msg"></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="m_1455031498856370709bloop_original_html gmail_msg"><div id="m_1455031498856370709bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto" class="gmail_msg"><br class="gmail_msg"></div> <br class="gmail_msg"> <div id="m_1455031498856370709bloop_sign_1480795002249061120" class="m_1455031498856370709bloop_sign gmail_msg"><div style="font-family:helvetica,arial;font-size:13px" class="gmail_msg">-- <br class="gmail_msg">Adrian Zubarev<br class="gmail_msg">Sent with Airmail</div></div> <br class="gmail_msg"></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="m_1455031498856370709bloop_original_html gmail_msg"><p class="m_1455031498856370709airmail_on gmail_msg">Am 3. Dezember 2016 um 20:29:05, Xiaodi Wu (<a href="mailto:xiaodi.wu@gmail.com" class="gmail_msg" target="_blank">xiaodi.wu@gmail.com</a>) schrieb:</p> <blockquote type="cite" class="m_1455031498856370709clean_bq gmail_msg"><span class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"></div><div class="gmail_msg">
<div dir="ltr" class="gmail_msg">On Sat, Dec 3, 2016 at 12:02 PM, Daniel Leping via
swift-evolution <span dir="ltr" class="gmail_msg"><<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br class="gmail_msg">
<div class="gmail_extra gmail_msg">
<div class="gmail_quote gmail_msg">
<blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr" class="gmail_msg">@Adrian, my comments inline below. Hope this
helps.<br class="gmail_msg">
<div class="gmail_extra gmail_msg"><br class="gmail_msg">
<div class="gmail_quote gmail_msg"><span class="gmail_msg">On Sat, Dec 3, 2016 at 6:22
PM, Adrian Zubarev <span dir="ltr" class="gmail_msg"><<a href="mailto:adrian.zubarev@devandartist.com" class="gmail_msg" target="_blank">adrian.zubarev@devandartist.com</a>></span>
wrote:<br class="gmail_msg"></span>
<blockquote class="gmail_quote gmail_msg" 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="gmail_msg">
<div class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134bloop_markdown gmail_msg">
<p class="gmail_msg">There is one thing that I want to point out with pitched
syntactic sugar. <code class="gmail_msg">GenericMyProtocolName<U></code> will
also let you reuse <code class="gmail_msg">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 class="gmail_msg">protocol
MyTProtocolName : MyProtocolName where U == T</code> would be
possible, so that <code class="gmail_msg">T</code> from the outer generic type is
accessible.</p>
<p class="gmail_msg">Autogenerating the only possible generic protocols from
protocols with associated types as a syntactic sugar to reduce
spawning of types like <code class="gmail_msg">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 class="gmail_msg">There are still a few more questioned to answer:</p>
<ul class="gmail_msg">
<li class="gmail_msg">How dow we want the generated parameter list to look like?</li>
</ul>
</div>
</div>
</blockquote>
<div class="gmail_msg"> 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>
<blockquote class="gmail_quote gmail_msg" 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="gmail_msg">
<div class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134bloop_markdown gmail_msg">
<ul class="gmail_msg">
<li class="gmail_msg"><span class="gmail_msg">Can we drop <code class="gmail_msg">Generic</code> prefix without
collisions?</span></li>
</ul>
</div>
</div>
</blockquote>
<div class="gmail_msg">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>
<blockquote class="gmail_quote gmail_msg" 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="gmail_msg">
<div class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134bloop_markdown gmail_msg">
<ul class="gmail_msg">
<li class="gmail_msg"><span class="gmail_msg">Does this syntactic sugar improves the stdlib or
affect ABI?</span></li>
</ul>
</div>
</div>
</blockquote>
<div class="gmail_msg">Don't see any implications. Assuming current stdlib doesn't
use the feature. It's rather an addition than change.</div>
<blockquote class="gmail_quote gmail_msg" 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="gmail_msg">
<div class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134bloop_markdown gmail_msg">
<p class="gmail_msg"><span class="gmail_msg">There are probably some more questions I cannot
foresee by myself. Feel free to jump in the discussion.
;)</span></p>
<p class="gmail_msg"><span class="gmail_msg">PS: Yes this syntactic sugar does create an
alternative way of creating ‘kinda’ the same protocol twice, but it
reuses the pattern more naturally.</span></p>
<pre class="gmail_msg"><span class="gmail_msg"><code class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134swift gmail_msg">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></span></pre></div>
</div>
</blockquote>
</div>
</div>
</div>
</blockquote>
<div class="gmail_msg"><br class="gmail_msg"></div>
<div class="gmail_msg">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 class="gmail_msg"> </div>
<blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr" class="gmail_msg">
<div class="gmail_extra gmail_msg">
<div class="gmail_quote gmail_msg">
<blockquote class="gmail_quote gmail_msg" 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="gmail_msg">
<div class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134bloop_markdown gmail_msg">
<pre class="gmail_msg"><span class="gmail_msg"><code class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134swift gmail_msg">// VS.
// autogenerated
procotol GenericFoo<Inner : SomeOtherProtocol> : Foo { … }
// usage
GenericFoo<String>
GenericFoo<Int>
// or
typealias StringFoo = GenericFoo<String>
typealias IntFoo = GenericFoo<Int></code></span></pre></div>
</div>
</blockquote>
<div class="gmail_msg">// The usage I propose is just do</div>
<div class="gmail_msg">typealias StringFoo = Foo<Inner = String></div>
<div class="gmail_msg"><br class="gmail_msg"></div>
<div class="gmail_msg">//also in an inheritance like this:</div>
<div class="gmail_msg">class FooClass : Foo<Inner = String>, Foo<Inner =
Int> {</div>
<div class="gmail_msg">//My question here is, though: how do we access Inner from
FooClass<br class="gmail_msg"></div>
<div class="gmail_msg"><br class="gmail_msg"></div>
<div class="gmail_msg">//Like this?</div>
<div class="gmail_msg">typealias InnerInt = Foo<Inner = String>.Inner</div>
<div class="gmail_msg"><span class="gmail_msg">}</span></div>
<blockquote class="gmail_quote gmail_msg" 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="gmail_msg">
<div class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134bloop_markdown gmail_msg">
<pre class="gmail_msg"><span class="gmail_msg"> </span></pre></div>
</div>
</blockquote>
<blockquote class="gmail_quote gmail_msg" 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="gmail_msg">
<div class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134bloop_markdown gmail_msg">
<pre class="gmail_msg"><span class="gmail_msg"><code class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134swift gmail_msg">
</code></span></pre></div>
<div class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134bloop_original_html gmail_msg">
<div id="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134bloop_customfont" style="font-family:helvetica,arial;font-size:13px;color:rgb(0,0,0);margin:0px" class="gmail_msg">
<span class="gmail_msg"><br class="gmail_msg"></span></div>
<span class="gmail_msg"><br class="gmail_msg"></span>
<div id="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134bloop_sign_1480780772434896896" class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134bloop_sign gmail_msg">
<div style="font-family:helvetica,arial;font-size:13px" class="gmail_msg">
<span class="gmail_msg">-- <br class="gmail_msg">
Adrian Zubarev<br class="gmail_msg">
Sent with Airmail</span></div>
</div>
<span class="gmail_msg"><br class="gmail_msg"></span>
<div class="gmail_msg">
<div class="m_1455031498856370709m_-6431036212696460543gmail-h5 gmail_msg">
<p class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134airmail_on gmail_msg">Am 3.
Dezember 2016 um 16:43:43, Daniel Leping (<a href="mailto:daniel@crossroadlabs.xyz" class="gmail_msg" target="_blank">daniel@crossroadlabs.xyz</a>) schrieb:</p>
<blockquote type="cite" class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134clean_bq gmail_msg">
<div class="gmail_msg">
<div class="gmail_msg">
<div style="white-space:pre-wrap" class="gmail_msg"><span class="gmail_msg">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 class="gmail_msg">
<br class="gmail_msg">
Off topic:<br class="gmail_msg">
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.</span></div>
<span class="gmail_msg"><br class="gmail_msg"></span>
<div class="gmail_quote gmail_msg">
<div dir="ltr" class="gmail_msg"><span class="gmail_msg">On Sat, 3 Dec 2016 at 16:30 Adrian Zubarev
<<a href="mailto:adrian.zubarev@devandartist.com" class="gmail_msg" target="_blank">adrian.zubarev@devandartist.com</a>>
wrote:<br class="gmail_msg"></span></div>
<blockquote class="gmail_quote gmail_msg" 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_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134gmail_msg gmail_msg">
<div class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134m_6921161786416199282bloop_markdown m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134gmail_msg gmail_msg">
<p class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134gmail_msg gmail_msg">
<span class="gmail_msg">If I’m not mistaken here, <code class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134gmail_msg gmail_msg">extension
Foo where T == Int</code> will have an error of redeclaration
<code class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134gmail_msg gmail_msg">foo</code>
anyways.</span></p>
<p class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134gmail_msg gmail_msg"></p>
</div>
<div class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134m_6921161786416199282bloop_original_html m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134gmail_msg gmail_msg">
</div>
</div>
<div style="word-wrap:break-word" class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134gmail_msg gmail_msg">
<div class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134m_6921161786416199282bloop_original_html m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134gmail_msg gmail_msg">
<div id="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134m_6921161786416199282bloop_customfont" style="font-family:helvetica,arial;font-size:13px;color:rgb(0,0,0);margin:0px" class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134gmail_msg gmail_msg">
<span class="gmail_msg"><br class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134gmail_msg gmail_msg"></span></div>
<div id="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134m_6921161786416199282bloop_sign_1480775153794472960" class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134m_6921161786416199282bloop_sign m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134gmail_msg gmail_msg">
<div style="font-family:helvetica,arial;font-size:13px" class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134gmail_msg gmail_msg">
<span class="gmail_msg">-- <br class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134gmail_msg gmail_msg">
Adrian Zubarev<br class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134gmail_msg gmail_msg">
Sent with Airmail</span></div>
</div>
<span class="gmail_msg"><br class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134gmail_msg gmail_msg"></span></div>
</div>
<div style="word-wrap:break-word" class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134gmail_msg gmail_msg">
<div class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134m_6921161786416199282bloop_original_html m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134gmail_msg gmail_msg">
<p class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134m_6921161786416199282airmail_on m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134gmail_msg gmail_msg">
<span class="gmail_msg">Am 3. Dezember 2016 um 15:22:56, Adrian Zubarev (<a href="mailto:adrian.zubarev@devandartist.com" class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134gmail_msg gmail_msg" target="_blank">adrian.zubarev@devandartist.com</a>)
schrieb:</span></p>
<blockquote type="cite" class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134m_6921161786416199282clean_bq m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134gmail_msg gmail_msg">
<div class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134gmail_msg gmail_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_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134gmail_msg gmail_msg"><span class="gmail_msg"><span class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134gmail_msg gmail_msg"><code class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134m_6921161786416199282swift m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134gmail_msg gmail_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></span></pre></div>
</blockquote>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
<div class="m_1455031498856370709m_-6431036212696460543gmail-m_805315748064065134bloop_markdown gmail_msg">
</div>
</div>
</blockquote>
</div>
<br class="gmail_msg"></div>
</div>
<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
<br class="gmail_msg"></blockquote>
</div>
<br class="gmail_msg"></div>
</div>
</div></div></span></blockquote></div></div></blockquote></div>