<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 21, 2016, at 3:05 PM, Ramiro Feria Purón via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><b class="">Problem:</b><div class=""><br class=""></div><div class="">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=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">func</span><span style="font-variant-ligatures:no-common-ligatures" class=""> f&lt;T&gt;(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">_</span><span style="font-variant-ligatures:no-common-ligatures" class=""> t: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">T</span><span style="font-variant-ligatures:no-common-ligatures" class="">) {</span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; min-height: 13px;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp;&nbsp; &nbsp;</span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(0, 143, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures" class="">//..</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></div></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(0, 143, 0);" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">f</span><span style="font-variant-ligatures: no-common-ligatures;" class="">(5)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures" class="">// T inferred to be Int</span></div>
<div class=""><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">f</span><span style="font-family: menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;" class="">(</span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures;color:rgb(180,38,26)" class="">"xzcvzxcvx"</span><span style="font-family: menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;" class="">)&nbsp; </span><span style="color:rgb(0,143,0);font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures" class="">// T inferred to be string</span>&nbsp;</div><div class=""><br class=""></div><div class="">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=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">func</span><span style="font-variant-ligatures:no-common-ligatures" class=""> g&lt;T&gt;(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">_</span><span style="font-variant-ligatures:no-common-ligatures" class=""> x: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">Int</span><span style="font-variant-ligatures:no-common-ligatures" class="">) -&gt; [</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">T</span><span style="font-variant-ligatures:no-common-ligatures" class="">] {</span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; min-height: 13px;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp;&nbsp; &nbsp;</span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">var</span><span style="font-variant-ligatures:no-common-ligatures" class=""> result: [</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">T</span><span style="font-variant-ligatures:no-common-ligatures" class="">] = []</span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; min-height: 13px;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp;&nbsp; &nbsp;</span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(0, 143, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures" class="">//..</span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; min-height: 13px;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp;&nbsp; &nbsp;</span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">return</span><span style="font-variant-ligatures:no-common-ligatures" class=""> result</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">}</span></div></div><div class=""><br class=""></div><div class="">In such cases, the type parameters must be inferrable from the context:<br class=""></div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">g</span><span style="font-variant-ligatures:no-common-ligatures" class="">(7)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,0)" class="">// 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=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">let</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> array = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">g</span><span style="font-variant-ligatures: no-common-ligatures;" class="">(7)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures" class="">// 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=""><span style="font-variant-ligatures:no-common-ligatures" class=""></span></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">let</span><span style="font-variant-ligatures:no-common-ligatures" class=""> array: [</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">String</span><span style="font-variant-ligatures:no-common-ligatures" class="">] = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">g</span><span style="font-variant-ligatures:no-common-ligatures" class="">(7)&nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,0)" class="">// Ok: T&nbsp;inferred to be&nbsp;String</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,0)" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">let</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;array =&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">g</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&lt;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">String</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&gt;(7)&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures" class="">// Error: Cannot explicitly specialise generic function</span><br class=""></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(0, 143, 0);" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(0, 143, 0);" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(0, 143, 0);" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(0, 143, 0);" class=""><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small" class=""><b class="">Proposed Solution:</b></span></div><div class=""><br class=""></div><div class="">Allow explicit type parameters in generic function call:</div></div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">let</span><span style="font-variant-ligatures:no-common-ligatures" class=""> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">_</span><span style="font-variant-ligatures:no-common-ligatures" class=""> = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">g</span><span style="font-variant-ligatures:no-common-ligatures" class="">&lt;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">String</span><span style="font-variant-ligatures:no-common-ligatures" class="">&gt;(7) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color:rgb(0,143,0)" class="">// Ok</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><b style="color:rgb(34,34,34);font-family:arial,sans-serif" class="">Motivation<span style="font-size:11px" class="">:</span></b></span></div><div class=""><br class=""></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""></span></p><div class="">Consider the following contrived example:</div></div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">class</span><span style="font-variant-ligatures:no-common-ligatures" class=""> Vehicle {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">var</span><span style="font-variant-ligatures:no-common-ligatures" class=""> currentSpeed = 0</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(0, 143, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures" class="">//..</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; min-height: 13px;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">class</span><span style="font-variant-ligatures:no-common-ligatures" class=""> Bicycle: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">Vehicle</span><span style="font-variant-ligatures:no-common-ligatures" class=""> {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(0, 143, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures" class="">//..</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; min-height: 13px;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">class</span><span style="font-variant-ligatures:no-common-ligatures" class=""> Car: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">Vehicle</span><span style="font-variant-ligatures:no-common-ligatures" class=""> {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(0, 143, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures" class="">//..</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(4, 51, 255);" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">@discardableResult</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">func</span><span style="font-variant-ligatures:no-common-ligatures" class=""> processAll&lt;T: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">Vehicle</span><span style="font-variant-ligatures:no-common-ligatures" class="">&gt;(in vehicles: [</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">Vehicle</span><span style="font-variant-ligatures:no-common-ligatures" class="">], condition: (</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">Vehicle</span><span style="font-variant-ligatures:no-common-ligatures" class="">) -&gt; </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">Bool</span><span style="font-variant-ligatures:no-common-ligatures" class="">) -&gt; [</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">T</span><span style="font-variant-ligatures:no-common-ligatures" class="">] {</span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; min-height: 13px;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp;&nbsp; &nbsp;</span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">var</span><span style="font-variant-ligatures:no-common-ligatures" class=""> processed: [</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">T</span><span style="font-variant-ligatures:no-common-ligatures" class="">] = []</span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; min-height: 13px;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp;&nbsp; &nbsp;</span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">for</span><span style="font-variant-ligatures:no-common-ligatures" class=""> vehicle </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">in</span><span style="font-variant-ligatures:no-common-ligatures" class=""> vehicles {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">guard</span><span style="font-variant-ligatures:no-common-ligatures" class=""> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">let</span><span style="font-variant-ligatures:no-common-ligatures" class=""> t = vehicle </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">as</span><span style="font-variant-ligatures:no-common-ligatures" class="">? </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">T</span><span style="font-variant-ligatures:no-common-ligatures" class="">, condition(vehicle) </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">else</span><span style="font-variant-ligatures:no-common-ligatures" class=""> { </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">continue</span><span style="font-variant-ligatures:no-common-ligatures" class=""> }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,0)" class="">//..</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; processed.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">append</span><span style="font-variant-ligatures:no-common-ligatures" class="">(t)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; &nbsp; }</span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; min-height: 13px;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp;&nbsp; &nbsp;</span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">return</span><span style="font-variant-ligatures:no-common-ligatures" class=""> processed</span></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(4,51,255)" class="">











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

</span></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""></span></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">let</span><span style="font-variant-ligatures:no-common-ligatures" class=""> processedVehicles = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">processAll</span><span style="font-variant-ligatures:no-common-ligatures" class="">(in: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">vehicles</span><span style="font-variant-ligatures:no-common-ligatures" class="">, condition: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">aboveSpeedLimit</span><span style="font-variant-ligatures:no-common-ligatures" class="">)&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,0)" class="">// Uh, T inferred to be Vehicle!</span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,0)" class=""></span></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">let</span><span style="font-variant-ligatures:no-common-ligatures" class=""> processedCars: [</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">Car</span><span style="font-variant-ligatures:no-common-ligatures" class="">] = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">processAll</span><span style="font-variant-ligatures:no-common-ligatures" class="">(in: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">vehicles</span><span style="font-variant-ligatures:no-common-ligatures" class="">, condition: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">aboveSpeedLimit</span><span style="font-variant-ligatures:no-common-ligatures" class="">) &nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,0)" class="">// T&nbsp;inferred to be&nbsp;Car</span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,0)" class=""></span></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(0, 143, 0);" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">processAll</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&lt;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">Bicycle</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&gt;(in: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">vehicles</span><span style="font-variant-ligatures: no-common-ligatures;" class="">, condition: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">aboveSpeedLimit</span><span style="font-variant-ligatures: no-common-ligatures;" class="">) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures" class="">// This should be allowed under this proposal</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><b style="color:rgb(34,34,34);font-family:arial,sans-serif" class="">Notes<span style="font-size:11px" class="">:</span></b></span></div><div class=""><br class=""></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""></span></p><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""></span></p><div class="">If necessary, the (real life) Swift code that lead to the proposal could be shared.</div></div></div></div></blockquote><br class=""></div><div>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><br class=""></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>func unsafeBitCast&lt;T, U&gt;(_ x: T, to: U.Type) -&gt; U</div><div><br class=""></div><div>Even if we had the ability to provide explicit type arguments, we would *not* want to change this signature to</div><div><br class=""></div><div><div><span class="Apple-tab-span" style="white-space: pre;">        </span>func unsafeBitCast&lt;U, T&gt;(_ x: T) -&gt; U &nbsp; &nbsp; // bad idea</div><div class=""><br class=""></div><div class="">because while it makes the correct usage slightly cleaner:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>unsafeBitCast&lt;Int&gt;(something)<span class="Apple-tab-span" style="white-space:pre">        </span>// slightly prettier, but...</div><div class=""><br class=""></div><div class="">it would enable type inference to go wild with unsafe casts:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>foo(unsafeBitCast(something))<span class="Apple-tab-span" style="white-space:pre">        </span>// just cast it to.. whatever<span class="Apple-tab-span" style="white-space:pre">        </span></div></div><div><br class=""></div><div>which is… not great.</div><div><br class=""></div><div>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><br class=""></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>func f&lt;T&gt;() -&gt; Void { … } &nbsp; // error: T is not part of the signature of f()</div><div><br class=""></div><div>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><br class=""></div><div>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><br class=""></div><div>And, as Dave notes, it’s effectively syntactic sugar, so it belongs in Swift 4 stage 2.</div><div><br class=""></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>- Doug</div><div><br class=""></div><br class=""></body></html>