<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 28, 2016, at 10:11 PM, Douglas Gregor 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 style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" class=""><div class=""><br class="Apple-interchange-newline">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 class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">func</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>f&lt;T&gt;(</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">_</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>t:<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">T</span><span class="" style="font-variant-ligatures: no-common-ligatures;">) {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; min-height: 13px;" class=""><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;&nbsp; &nbsp;</span><br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(0, 143, 0);"><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures;">//..</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">}</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><br class=""></span></div></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(0, 143, 0);"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">f</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(5)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures;">// T inferred to be Int</span></div><div class=""><span class="" style="font-family: menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">f</span><span class="" style="font-family: menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;">(</span><span class="" style="font-family: menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures; color: rgb(180, 38, 26);">"xzcvzxcvx"</span><span class="" style="font-family: menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;">)&nbsp;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="color: rgb(0, 143, 0); font-family: menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;">// 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 class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">func</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>g&lt;T&gt;(</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">_</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>x:<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">Int</span><span class="" style="font-variant-ligatures: no-common-ligatures;">) -&gt; [</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">T</span><span class="" style="font-variant-ligatures: no-common-ligatures;">] {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; min-height: 13px;" class=""><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;&nbsp; &nbsp;</span><br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">var</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>result: [</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">T</span><span class="" style="font-variant-ligatures: no-common-ligatures;">] = []</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; min-height: 13px;" class=""><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;&nbsp; &nbsp;</span><br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(0, 143, 0);"><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures;">//..</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; min-height: 13px;" class=""><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;&nbsp; &nbsp;</span><br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">return</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>result</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">}</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 class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">g</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(7)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 143, 0);">// Error: T cannot be inferred</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(0, 143, 0);"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>array =<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">g</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(7)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures;">// Error: T cannot be inferred</span></div><p class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(0, 143, 0);"><span class="" style="font-variant-ligatures: no-common-ligatures;"></span></p><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>array: [</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">String</span><span class="" style="font-variant-ligatures: no-common-ligatures;">] =<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">g</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(7)&nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 143, 0);">// Ok: T&nbsp;inferred to be&nbsp;String</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 143, 0);"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;array =&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">g</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&lt;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">String</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&gt;(7)&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures;">// Error: Cannot explicitly specialise generic function</span><br class=""></span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(0, 143, 0);"><span class="" style="font-variant-ligatures: no-common-ligatures;"><br class=""></span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(0, 143, 0);"><span class="" style="font-variant-ligatures: no-common-ligatures;"><br class=""></span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(0, 143, 0);"><span class="" style="font-variant-ligatures: no-common-ligatures;"><br class=""></span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(0, 143, 0);"><span class="" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small;"><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 class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">_</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>=<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">g</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&lt;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">String</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&gt;(7) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span class="" style="color: rgb(0, 143, 0);">// Ok</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><br class=""></span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><br class=""></span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><br class=""></span></div><div class="" style="margin: 0px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><b class="" style="color: rgb(34, 34, 34); font-family: arial, sans-serif;">Motivation<span class="" style="font-size: 11px;">:</span></b></span></div><div class=""><br class=""></div><p class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"></span></p><div class="">Consider the following contrived example:</div></div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">class</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>Vehicle {</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">var</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>currentSpeed = 0</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(0, 143, 0);"><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures;">//..</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">}</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; min-height: 13px;"><span class="" style="font-variant-ligatures: no-common-ligatures;"></span><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">class</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>Bicycle:<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">Vehicle</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>{</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(0, 143, 0);"><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures;">//..</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">}</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; min-height: 13px;"><span class="" style="font-variant-ligatures: no-common-ligatures;"></span><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">class</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>Car:<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">Vehicle</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>{</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(0, 143, 0);"><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures;">//..</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">}</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><br class=""></span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(4, 51, 255);"><span class="" style="font-variant-ligatures: no-common-ligatures;">@discardableResult</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">func</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>processAll&lt;T:<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">Vehicle</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&gt;(in vehicles: [</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">Vehicle</span><span class="" style="font-variant-ligatures: no-common-ligatures;">], condition: (</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">Vehicle</span><span class="" style="font-variant-ligatures: no-common-ligatures;">) -&gt;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">Bool</span><span class="" style="font-variant-ligatures: no-common-ligatures;">) -&gt; [</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">T</span><span class="" style="font-variant-ligatures: no-common-ligatures;">] {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; min-height: 13px;" class=""><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;&nbsp; &nbsp;</span><br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">var</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>processed: [</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">T</span><span class="" style="font-variant-ligatures: no-common-ligatures;">] = []</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; min-height: 13px;" class=""><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;&nbsp; &nbsp;</span><br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">for</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>vehicle<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">in</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>vehicles {</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">guard</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>t = vehicle<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">as</span><span class="" style="font-variant-ligatures: no-common-ligatures;">?<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">T</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, condition(vehicle)<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">else</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>{<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">continue</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>}</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 143, 0);">//..</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp; &nbsp; &nbsp; &nbsp; processed.</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">append</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(t)</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp; &nbsp; }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; min-height: 13px;" class=""><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;&nbsp; &nbsp;</span><br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">return</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>processed</span></div><p class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(4, 51, 255);"></p><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">}</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><br class=""></span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">func</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>aboveSpeedLimit(vehicle:<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">Vehicle</span><span class="" style="font-variant-ligatures: no-common-ligatures;">) -&gt;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">Bool</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>{</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">return</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>vehicle.</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">currentSpeed</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;&gt;= 100</span></div><p class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"></span></p><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">}</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><br class=""></span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><br class=""></span></div><p class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"></span></p><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>processedVehicles =<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">processAll</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(in:<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">vehicles</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, condition:<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">aboveSpeedLimit</span><span class="" style="font-variant-ligatures: no-common-ligatures;">)&nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 143, 0);">// Uh, T inferred to be Vehicle!</span></div><p class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 143, 0);"></span></p><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>processedCars: [</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">Car</span><span class="" style="font-variant-ligatures: no-common-ligatures;">] =<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">processAll</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(in:<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">vehicles</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, condition:<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">aboveSpeedLimit</span><span class="" style="font-variant-ligatures: no-common-ligatures;">) &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 143, 0);">// T&nbsp;inferred to be&nbsp;Car</span></div><p class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 143, 0);"></span></p><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(0, 143, 0);"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">processAll</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&lt;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">Bicycle</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&gt;(in:<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">vehicles</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, condition:<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">aboveSpeedLimit</span><span class="" style="font-variant-ligatures: no-common-ligatures;">) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures;">// This should be allowed under this proposal</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><br class=""></span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><br class=""></span></div><div class="" style="margin: 0px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><b class="" style="color: rgb(34, 34, 34); font-family: arial, sans-serif;">Notes<span class="" style="font-size: 11px;">:</span></b></span></div><div class=""><br class=""></div><p class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"></span></p><p class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"></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 style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">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 style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><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 style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Even if we had the ability to provide explicit type arguments, we would *not* want to change this signature to</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class=""><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></div></blockquote><div><br class=""></div><div>Angle brackets in function calls are hideous. This is objectively more clear and much prettier IMO:</div><div><br class=""></div><div>&nbsp; unsafeBitCast(something, to: Int)</div><br class=""><blockquote type="cite" class=""><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><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 style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">which is… not great.</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">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 style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><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 style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">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 style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">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></blockquote><div><br class=""></div>+1 for required type parameters being normal parameters.</div><div><br class=""></div><div>I think the case mentioned in the proposal reads much better as:</div><div><br class=""></div><div>&nbsp; processAll(in:&nbsp;vehicles, as: Bicycle, condition:&nbsp;aboveSpeedLimit)<br class=""></div><div><br class=""></div><div>If angle brackets can be limited to generic definitions and type names, that’s a great accomplishment.</div><div><br class=""></div><div>-Andy</div><div><br class=""></div><div><blockquote type="cite" class=""><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">And, as Dave notes, it’s effectively syntactic sugar, so it belongs in Swift 4 stage 2.</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>- Doug</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:swift-evolution@swift.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">swift-evolution@swift.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></body></html>