<div dir="ltr">What about templatetype ? This could also work if we started referring generics as Templates :) and extended them to protocols and functions. <div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Dec 26, 2015 at 3:15 PM, Ross O&#39;Brien <span dir="ltr">&lt;<a href="mailto:narrativium+swift@gmail.com" target="_blank">narrativium+swift@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">There&#39;s a problem here because associated types aren&#39;t the same as generics.<div><br></div><div>I&#39;ve been looking this up a lot recently because I&#39;ve been trying to create a delegate protocol for a generic type. The GenericType&lt;X&gt; requires a GenericTypeDelegate&lt;X&gt; and Swift 2 protocols just don&#39;t support those yet; the best workaround of the moment seems to be a wrapper type which wraps the delegate&#39;s functions in closures.</div><div><br></div><div>This is a different concept to associated types. I&#39;ve seen a couple of examples around; the one I&#39;m remembering at the moment involves a protocol for Animals requiring them to have an associated Food type. A Cow could thus be defined as a type implementing the Animal protocol, with an associated type of Grass; this would be very different to an Animal being a generic type, and a Cow being (perhaps typealiased as) an Animal&lt;Grass&gt;. With the associated type, the Cow is known to always eat Grass; with the generic type, every function is written to handle all foodstuffs.</div><div><br></div><div>So, no, the two different syntaxes are required - but protocols with generic parameters (is that the right term for e.g. Grass in Animal&lt;Grass&gt;?) would be a good addition to the language.</div><div><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Wed, Dec 23, 2015 at 11:06 PM, James Campbell via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">If we made class, structs, protocols and functions use the same generics syntax then I think it would make it more consistent rather than arguing about which keyword to use. I am for-ever being tripped up by lack of generics in the language.<div><br></div><div>class Array&lt;T&gt;</div><div>{ </div><div>func first() -&gt; T?</div><div>}</div><div><br></div><div>struct Node&lt;Value&gt;</div><div>{</div><div>var value: Value</div><div>}</div><div><br></div><div>Array&lt;Int&gt;()</div><div>Node&lt;Int&gt;()<br></div><div><br></div><div>or</div><div><br></div><div>func makeACell&lt;T&gt;() -&gt; T</div><div>{</div><div>}</div><div><br></div><div>makeACell&lt;MyCell&gt;()</div><div><br></div><div>or</div><div><br></div><div>protocol Collection&lt;Item&gt;</div><div>{</div><div>func first() -&gt; Item?</div><div>}</div><div><br></div><div>class IntBag : Collection&lt;Int&gt; //We bind protocol &quot;associated type&quot; using generic syntax when subclassing. In this case we are saying Item should be type Int</div><div>{</div><div>}</div><div><br></div><div>class Array&lt;Item&gt;: Collection&lt;Item&gt; //We bind protocol &quot;associated type&quot; using generic syntax when subclassing. In this case we are saying Item should be the same type as the generic type for Array</div><div>{</div><div>}</div><div><br></div><div>IntBag()</div><div>Array&lt;Int&gt;()</div><div><br></div></div></div></div><div><div><div><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 23, 2015 at 10:58 PM, James Campbell <span dir="ltr">&lt;<a href="mailto:james@supmenow.com" target="_blank">james@supmenow.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">They are placeholders because in the protocol:<div><br></div><div>prtocotol Collection</div><div>{</div><div>  placeholder Item</div><div><br></div><div>  func first() -&gt; Item?</div><div> {</div><div> }</div><div>}</div><div><br></div><div>Item is a placeholder for a concrete type, at this moment this is a concept &quot;A collection should return an item of a type&quot; but we don&#39;t know what that type is as its a plaeholder for a type.</div><div><br></div><div>therefore in:</div><div><br></div><div>class IntCollection: Collection</div><div>{</div><div>   placeholder Item = Int</div><div>}</div><div><br></div><div>We are saying that the placeholder should now become a concrete type. In my eyes associated types are nothing more than generics for protocols which in turn could be argued is some kind of placeholder.</div><div><br></div><div>Associated type means nothing to me, associated to what ? A type could be associated to many things like a variable, or a generic or whatever. A placeholder to mean does what it says on the tin. If we moved to protocols using a syntax closer to generics for classes then I think it would be simpilar to grasp for beginners .</div></div><div class="gmail_extra"><div><div><br><div class="gmail_quote">On Wed, Dec 23, 2015 at 9:35 PM, Jordan Rose <span dir="ltr">&lt;<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">James or Erica (or someone else), can you explain what makes these types &quot;placeholders&quot;? I don&#39;t think of the other requirements in a protocol as &quot;placeholder properties&quot; or &quot;placeholder methods&quot;.<br>
<br>
My explanation of these things is &quot;When a particular type X conforms to a protocol, you can ask about the types that X uses to implement the requirements of the protocol&quot;. I guess we could call them &quot;related types&quot; instead of &quot;associated types&quot;, but that doesn&#39;t seem significantly different.<br>
<span><font color="#888888"><br>
Jordan<br>
</font></span><div><div><br>
<br>
&gt; On Dec 23, 2015, at 12:42, James Campbell via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;<br>
&gt; The thing is associated type means nothing to me, it&#39;s too technical. Placeholder type I think would be better even if it&#39;s only what we called it in the documentation<br>
&gt;<br>
&gt; Sent from my iPhone<br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div></div></div><span>-- <br><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><span style="font-size:16px;line-height:19.2px"></span><span style="font-size:12.8px"> Wizard</span><br></div><div><a href="mailto:james@supmenow.com" target="_blank">james@supmenow.com</a></div><div><a href="tel:%2B44%207523%20279%20698" value="+447523279698" target="_blank">+44 7523 279 698</a></div></div></div></div></div></div>
</span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><span style="font-size:16px;line-height:19.2px"></span><span style="font-size:12.8px"> Wizard</span><br></div><div><a href="mailto:james@supmenow.com" target="_blank">james@supmenow.com</a></div><div><a href="tel:%2B44%207523%20279%20698" value="+447523279698" target="_blank">+44 7523 279 698</a></div></div></div></div></div></div>
</div>
</div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=-2F-2BoYEebT9nJ6Tn1eM4dmwhL8-2BwH5ixcf4jim0iIuN5xsol0n5xfoQcQbEATBpx0KJhcnzMUmjSf-2FK7ly-2F5S2KSgYxS37SzndZAvC92FGJpBvV210tyuGmhLDAAgs4SFqNbM-2BhBTll3-2F371BeBVpCSI5-2Fd05XMmfuuhryyoSzzUhEdN2iRhkdj-2BRoOQQsum3FObMFyZReDva3uxuQWVjzBAhrXv8D4tPle9LsLj3NEgg-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important">
</div></div><span class=""><br>_______________________________________________<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>
<br></span></blockquote></div><br></div></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><span style="font-size:16px;line-height:19.2px"></span><span style="font-size:12.8px"> Wizard</span><br></div><div><a href="mailto:james@supmenow.com" target="_blank">james@supmenow.com</a></div><div>+44 7523 279 698</div></div></div></div></div></div>
</div>