<div dir="ltr">Formally, perhaps the proposal should include the following:<div><br></div><div>1. Missing type parameters are assumed to be implicit and trailing (as in the particular case of all type parameters missing).</div><div><br></div><div>2. _ is allowed as a placeholder when specifying explicit parameters in a function call. The corresponding parameter is assumed to be implicit.</div><div><br></div><div>In addition to this, and following the discussion on the <span style="font-family:menlo;font-size:11px">unsafeBitCast </span>example, it might be a good idea to incorporate to the proposal adding an (optional) <span style="color:rgb(4,51,255);font-family:menlo;font-size:11px">explicit</span> keyword for type parameters in generic function definitions:</div><div><br></div><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">func</span><span style="font-variant-ligatures:no-common-ligatures"> unsafeBitCast&lt;<span style="color:rgb(4,51,255)">explicit</span> U, T&gt;(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">_</span><span style="font-variant-ligatures:no-common-ligatures"> x: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">T</span><span style="font-variant-ligatures:no-common-ligatures">) -&gt; </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">U</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,143,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">foo(unsafeBitCast(something))      </span><span style="font-variant-ligatures:no-common-ligatures">// error: explicit type parameter required</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures">foo(unsafeBitCast&lt;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">U</span><span style="font-variant-ligatures:no-common-ligatures">&gt;(something))   </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,0)">// ok</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,0)"><br></span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><br></p><p style="margin:0px;line-height:normal">Regards,</p><p style="margin:0px;line-height:normal">Ramiro<br></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><br></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><br></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><br></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><br></p></div><div><div class="gmail_quote"><div dir="ltr">On Thu, 1 Dec 2016 at 01:36 Ramiro Feria Purón &lt;<a href="mailto:ramiro.feria.puron@gmail.com">ramiro.feria.puron@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg">Or perhaps in a more &quot;swifty&quot; way, use _ for implicit type parameters, i.e.:<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><span class="gmail_msg" style="color:rgb(52,149,175);font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures">f&lt;_,T&gt;</span><span class="gmail_msg" style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures">(</span><span class="gmail_msg" style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures">)</span><br class="gmail_msg"></div></div><br class="gmail_msg"><div class="gmail_quote gmail_msg"><div dir="ltr" class="gmail_msg">On Thu, 1 Dec 2016 at 01:13 Ramiro Feria Purón &lt;<a href="mailto:ramiro.feria.puron@gmail.com" class="gmail_msg" target="_blank">ramiro.feria.puron@gmail.com</a>&gt; wrote:<br 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">Douglas,<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Regarding the question on the restriction for type parameters to appear on the signature, the answer is remain. The proposal does not intend this restriction to be lifted.</div><div class="gmail_msg"><br class="gmail_msg" style="font-size:13px;white-space:pre-wrap"><span style="font-size:13px;white-space:pre-wrap" class="gmail_msg">One might expect to find a few legitimate cases where having it lifted would be handy or desirable. They seem to emerge often, for example, while developing components using Core Data. From a real case scenario:</span></div><div class="gmail_msg"><span style="font-size:13px;white-space:pre-wrap" class="gmail_msg"><br class="gmail_msg"></span></div><div class="gmail_msg"><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">protocol</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> Activable { </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">var</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> dateLastActive: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">Date</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> { </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">get</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> } </span>}</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span><br class="gmail_msg"></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(52,149,175)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">class</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)" class="gmail_msg"> A: </span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">NSManagedObject</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)" class="gmail_msg"> {}</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(52,149,175)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">class</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)" class="gmail_msg"> B: </span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">NSManagedObject</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)" class="gmail_msg"> {}</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,143,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">//..</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(52,149,175)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">class</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)" class="gmail_msg"> Z: </span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">NSManagedObject</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)" class="gmail_msg"> {}</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span><br class="gmail_msg"></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">extension</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">A</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">Activable</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> { </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">var</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> dateLastActive: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">Date</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> { </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">return</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">Date</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">() } }</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">extension</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">B</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">Activable</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> { </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">var</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> dateLastActive: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">Date</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> { </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">return</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">Date</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">() } }</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,143,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">//..</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">extension</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">Z</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">Activable</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> { </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">var</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> dateLastActive: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">Date</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> { </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">return</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">Date</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">() } }</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span><br class="gmail_msg"></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span><br class="gmail_msg"></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span><br class="gmail_msg"></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">func</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> deleteInactiveObjects&lt;T: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">NSManagedObject</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&gt;(since date: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">Date</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">, inContext context: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">NSManagedObjectContext</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">) </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">where</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">T</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">Activable</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> {</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,143,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)" class="gmail_msg">    </span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">//..</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">}</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span><br class="gmail_msg"></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,143,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">// for the sake of the example</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(52,149,175)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">let</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)" class="gmail_msg"> context = </span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">NSManagedObjectContext</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)" class="gmail_msg">(concurrencyType: .</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">privateQueueConcurrencyType</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)" class="gmail_msg">)</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">let</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> yesterday = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">Date</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">()</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">let</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> oneWeekAgo = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">Date</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">()</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span><br class="gmail_msg"></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span><br class="gmail_msg"></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(52,149,175)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">deleteInactiveObjects&lt;A&gt;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)" class="gmail_msg">(since: </span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">yesterday</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)" class="gmail_msg">, inContext: </span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">context</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)" class="gmail_msg">)</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(52,149,175)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">deleteInactiveObjects&lt;B&gt;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)" class="gmail_msg">(since: </span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">oneWeekAgo</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)" class="gmail_msg">, inContext: </span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">context</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)" class="gmail_msg">)</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,143,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">//..</span></p></div><div class="gmail_msg"><span style="font-size:13px;white-space:pre-wrap" class="gmail_msg"><br class="gmail_msg"></span></div><div class="gmail_msg"><span style="font-size:13px;white-space:pre-wrap" class="gmail_msg">(here again, as you mention, the parameter affects how the function operates, yet it is not part of the signature)</span></div><div class="gmail_msg"><span style="font-size:13px;white-space:pre-wrap" class="gmail_msg"><br class="gmail_msg"></span></div><div class="gmail_msg"><span style="font-size:13px;white-space:pre-wrap" class="gmail_msg">If the restriction was lifted, however, it </span><span style="font-size:13px;white-space:pre-wrap" class="gmail_msg">would also be in detriment of the educational value of the proposal (</span><span style="font-size:13px;white-space:pre-wrap" class="gmail_msg">apart from your arguments above)</span><span style="font-size:13px;white-space:pre-wrap" class="gmail_msg">. </span><span style="font-size:13px;white-space:pre-wrap" class="gmail_msg">When defining a generic function, it feels natural to expect all of the type parameters to be present in the generic function signature. Relaxing this rule could be perceived by the novice as an invitation to an obscure design. In the best case, it would generate doubts about its actual intent. </span></div><div class="gmail_msg"><br class="gmail_msg" style="font-size:13px;white-space:pre-wrap"><span style="font-size:13px;white-space:pre-wrap" class="gmail_msg">From a pedagogical perspective, the proposal aims to save Swift from disappointment when this topic is brought to discussion, say whether at the end of a Programming or a Compilers undergraduate course -- albeit fully understanding (or implementing) the current alternatives could be an excellent exercise for the class.</span></div><div class="gmail_msg"><span style="font-size:13px;white-space:pre-wrap" class="gmail_msg"><br class="gmail_msg"></span></div><div class="gmail_msg"><span style="font-size:13px;white-space:pre-wrap" class="gmail_msg">From the (primary) language and development perspective, I don&#39;t think it could be expressed in a better way than in your lines, which are truly appreciated:</span></div></div><div dir="ltr" class="gmail_msg"><div class="gmail_msg"><span style="font-size:13px;white-space:pre-wrap" class="gmail_msg"><br class="gmail_msg"></span></div><div class="gmail_msg"><span style="font-size:13px" class="gmail_msg">&quot;<i class="gmail_msg">That’s how I see this proposal: not as a replacement for the metatype parameter idiom that unsafeBitCast uses, but as a way to be more explicit at particular call sites when type inference either fails (e.g., due to lack of contextual type information), produces a result different than what is desired, or is sufficiently complicated that the call site requires more documentation.</i><span style="white-space:pre-wrap" class="gmail_msg">&quot;</span></span></div><div class="gmail_msg"><span style="font-size:13px;white-space:pre-wrap" class="gmail_msg"><br class="gmail_msg"></span></div></div><div dir="ltr" class="gmail_msg"><div class="gmail_msg"><span style="white-space:pre-wrap" class="gmail_msg">Finally, we should also consider the possibility of being explicit about some but not all type parameters. If allowed, something like &quot;only trailing type parameters could be missing&quot; would be necessary to avoid ambiguity.</span></div><div class="gmail_msg"><span style="white-space:pre-wrap" class="gmail_msg"><br class="gmail_msg"></span></div><div class="gmail_msg"><span style="white-space:pre-wrap" class="gmail_msg">All the best,</span></div><div class="gmail_msg"><span style="white-space:pre-wrap" class="gmail_msg">Ramiro</span></div></div><div dir="ltr" class="gmail_msg"><div class="gmail_msg"><span style="white-space:pre-wrap" class="gmail_msg"><br class="gmail_msg"></span></div><div class="gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg"><div dir="ltr" class="gmail_msg">On Tue, 29 Nov 2016 at 17:11 Douglas Gregor &lt;<a href="mailto:dgregor@apple.com" class="gmail_msg" target="_blank">dgregor@apple.com</a>&gt; wrote:<br 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 style="word-wrap:break-word" class="gmail_msg"><br class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Nov 21, 2016, at 3:05 PM, Ramiro Feria Purón via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_-7637062993085499428m_2793299352371213050m_6032648967616326866Apple-interchange-newline gmail_msg"><div class="gmail_msg"><div dir="ltr" class="gmail_msg"><b class="gmail_msg">Problem:</b><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Currently, it is not possible to be explicit about the generic parameters (type parameters) in a generic function call. Type parameters are inferred from actual parameters:</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">func</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> f&lt;T&gt;(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">_</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> t: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">T</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">) {</span></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">    </span><br class="m_-7637062993085499428m_2793299352371213050m_6032648967616326866webkit-block-placeholder gmail_msg"></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,143,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">    </span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">//..</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">}</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><br class="gmail_msg"></span></div></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,143,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">f</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">(5)            </span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">// T inferred to be Int</span></div>
<div class="gmail_msg"><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">f</span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures" class="gmail_msg">(</span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures;color:rgb(180,38,26)" class="gmail_msg">&quot;xzcvzxcvx&quot;</span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures" class="gmail_msg">)  </span><span style="color:rgb(0,143,0);font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures" class="gmail_msg">// T inferred to be string</span> </div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">If no type parameter is involved in the formal parameters, the type parameter needs to be used somehow as part of the return type. For example:</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">func</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> g&lt;T&gt;(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">_</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> x: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">Int</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">) -&gt; [</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">T</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">] {</span></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">    </span><br class="m_-7637062993085499428m_2793299352371213050m_6032648967616326866webkit-block-placeholder gmail_msg"></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">    </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">var</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> result: [</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">T</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">] = []</span></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">    </span><br class="m_-7637062993085499428m_2793299352371213050m_6032648967616326866webkit-block-placeholder gmail_msg"></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,143,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">    </span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">//..</span></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">    </span><br class="m_-7637062993085499428m_2793299352371213050m_6032648967616326866webkit-block-placeholder gmail_msg"></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">    </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">return</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> result</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">}</span></div></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">In such cases, the type parameters must be inferrable from the context:<br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">g</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">(7)                            </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,0)" class="gmail_msg">// Error: T cannot be inferred</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,143,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">let</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> array = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">g</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">(7)                </span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">// Error: T cannot be inferred</span></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,143,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">let</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> array: [</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">String</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">] = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">g</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">(7)      </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,0)" class="gmail_msg">// Ok: T inferred to be String</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">let</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> array = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">g</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&lt;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">String</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&gt;(7)        </span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">// Error: Cannot explicitly specialise generic function</span><br class="gmail_msg"></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,143,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><br class="gmail_msg"></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,143,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><br class="gmail_msg"></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,143,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><br class="gmail_msg"></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,143,0)" class="gmail_msg"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small" class="gmail_msg"><b class="gmail_msg">Proposed Solution:</b></span></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Allow explicit type parameters in generic function call:</div></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">let</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">_</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">g</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&lt;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">String</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&gt;(7)            </span><span style="color:rgb(0,143,0)" class="gmail_msg">// Ok</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><br class="gmail_msg"></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><br class="gmail_msg"></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><br class="gmail_msg"></span></div><div style="margin:0px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><b style="color:rgb(34,34,34);font-family:arial,sans-serif" class="gmail_msg">Motivation<span style="font-size:11px" class="gmail_msg">:</span></b></span></div><div class="gmail_msg"><br class="gmail_msg"></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span></p><div class="gmail_msg">Consider the following contrived example:</div></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">class</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> Vehicle {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">    </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">var</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> currentSpeed = 0</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,143,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">    </span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">//..</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">}</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span><br class="gmail_msg"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">class</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> Bicycle: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">Vehicle</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,143,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">    </span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">//..</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">}</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span><br class="gmail_msg"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">class</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> Car: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">Vehicle</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,143,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">    </span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">//..</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">}</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><br class="gmail_msg"></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(4,51,255)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">@discardableResult</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">func</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> processAll&lt;T: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">Vehicle</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&gt;(in vehicles: [</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">Vehicle</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">], condition: (</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">Vehicle</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">) -&gt; </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">Bool</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">) -&gt; [</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">T</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">] {</span></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">    </span><br class="m_-7637062993085499428m_2793299352371213050m_6032648967616326866webkit-block-placeholder gmail_msg"></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">    </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">var</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> processed: [</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">T</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">] = []</span></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">    </span><br class="m_-7637062993085499428m_2793299352371213050m_6032648967616326866webkit-block-placeholder gmail_msg"></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">    </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">for</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> vehicle </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">in</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> vehicles {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">        </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">guard</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">let</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> t = vehicle </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">as</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">? </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">T</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">, condition(vehicle) </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">else</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> { </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">continue</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> }</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">        </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,0)" class="gmail_msg">//..</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">        processed.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">append</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">(t)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">    }</span></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">    </span><br class="m_-7637062993085499428m_2793299352371213050m_6032648967616326866webkit-block-placeholder gmail_msg"></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">    </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">return</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> processed</span></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(4,51,255)" class="gmail_msg">











</p><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">}</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><br class="gmail_msg"></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">func</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> aboveSpeedLimit(vehicle: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">Vehicle</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">) -&gt; </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">Bool</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">    </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">return</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> vehicle.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">currentSpeed</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> &gt;= 100</span></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">

</span></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">}</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><br class="gmail_msg"></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><br class="gmail_msg"></span></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">let</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> processedVehicles = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">processAll</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">(in: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">vehicles</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">, condition: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">aboveSpeedLimit</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">)        </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,0)" class="gmail_msg">// Uh, T inferred to be Vehicle!</span></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,0)" class="gmail_msg"></span></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="gmail_msg">let</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> processedCars: [</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">Car</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">] = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">processAll</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">(in: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">vehicles</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">, condition: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">aboveSpeedLimit</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">)     </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,0)" class="gmail_msg">// T inferred to be Car</span></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,0)" class="gmail_msg"></span></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,143,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">processAll</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&lt;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">Bicycle</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&gt;(in: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">vehicles</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">, condition: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="gmail_msg">aboveSpeedLimit</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">)                       </span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">// This should be allowed under this proposal</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><br class="gmail_msg"></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><br class="gmail_msg"></span></div><div style="margin:0px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><b style="color:rgb(34,34,34);font-family:arial,sans-serif" class="gmail_msg">Notes<span style="font-size:11px" class="gmail_msg">:</span></b></span></div><div class="gmail_msg"><br class="gmail_msg"></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span></p><div class="gmail_msg">If necessary, the (real life) Swift code that lead to the proposal could be shared.</div></div></div></div></blockquote><br class="gmail_msg"></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg">This seems completely reasonable to me. I had always expected us to implement this feature, but we never got around to it, and it wasn’t a high priority because one can always use type inference. Additionally, there were a few places where we originally thought we wanted this feature, but prefer the more-explicit form where the user is required to explicitly pass along a metatype. unsafeBitCast is one such case:</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><span class="m_-7637062993085499428m_2793299352371213050m_6032648967616326866Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span>func unsafeBitCast&lt;T, U&gt;(_ x: T, to: U.Type) -&gt; U</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Even if we had the ability to provide explicit type arguments, we would *not* want to change this signature to</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div class="gmail_msg"><span class="m_-7637062993085499428m_2793299352371213050m_6032648967616326866Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span>func unsafeBitCast&lt;U, T&gt;(_ x: T) -&gt; U     // bad idea</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">because while it makes the correct usage slightly cleaner:</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><span class="m_-7637062993085499428m_2793299352371213050m_6032648967616326866Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span>unsafeBitCast&lt;Int&gt;(something)<span class="m_-7637062993085499428m_2793299352371213050m_6032648967616326866Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span>// slightly prettier, but...</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">it would enable type inference to go wild with unsafe casts:</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><span class="m_-7637062993085499428m_2793299352371213050m_6032648967616326866Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span>foo(unsafeBitCast(something))<span class="m_-7637062993085499428m_2793299352371213050m_6032648967616326866Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span>// just cast it to.. whatever<span class="m_-7637062993085499428m_2793299352371213050m_6032648967616326866Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span></div></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">which is… not great.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">I’d like one bit of clarification in the proposal. Right now, one is not permitted to have a type parameter in a generic function that isn’t used somewhere in its signature, e.g.,</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><span class="m_-7637062993085499428m_2793299352371213050m_6032648967616326866Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span>func f&lt;T&gt;() -&gt; Void { … }   // error: T is not part of the signature of f()</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">This restriction is obvious in today’s Swift, because there is absolutely no way one could ever use this function. With your proposed extension, it would be possible to use this function. Does the restriction remain or is it lifted?</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Personally, I’d like the restriction to stay, because it feels like such functions fall into the same camp as unsafeBitCast: if the type parameter affects how the function operates but is *not* part of its signature, then it should be expressed like a normal parameter (of a metatype). It also helps provide better diagnostics when changing a generic function to no longer require one of its type parameters.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">And, as Dave notes, it’s effectively syntactic sugar, so it belongs in Swift 4 stage 2.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><span class="m_-7637062993085499428m_2793299352371213050m_6032648967616326866Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span>- Doug</div><div class="gmail_msg"><br class="gmail_msg"></div><br class="gmail_msg"></div></blockquote></div></div></div></blockquote></div></blockquote></div></div></div>