<div dir="ltr">Derrick,<div><br></div><div>This proposal is nothing but adding built-in language support for the code you have just written.</div><div><br></div><div>Regards,</div><div>Ramiro</div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-11-22 12:40 GMT+11:00 Derrick Ho <span dir="ltr">&lt;<a href="mailto:wh1pch81n@gmail.com" target="_blank">wh1pch81n@gmail.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>If you want to feed it a type rather than infer it from variable type or cast it using as! Then you can just add the type as a parameter…</div><div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2">func</span><span style="font-variant-ligatures:no-common-ligatures"> processAll&lt;T: </span><span style="font-variant-ligatures:no-common-ligatures;color:#4f8187">Vehicle</span><span style="font-variant-ligatures:no-common-ligatures">&gt;(type: </span><span style="font-variant-ligatures:no-common-ligatures;color:#4f8187">T</span><span style="font-variant-ligatures:no-common-ligatures">.Type, in vehicles: [</span><span style="font-variant-ligatures:no-common-ligatures;color:#4f8187">Vehicle</span><span style="font-variant-ligatures:no-common-ligatures">], condition: (</span><span style="font-variant-ligatures:no-common-ligatures;color:#4f8187">Vehicle</span><span style="font-variant-ligatures:no-common-ligatures">) -&gt; </span><span style="font-variant-ligatures:no-common-ligatures;color:#703daa">Bool</span><span style="font-variant-ligatures:no-common-ligatures">) -&gt; [</span><span style="font-variant-ligatures:no-common-ligatures;color:#4f8187">T</span><span style="font-variant-ligatures:no-common-ligatures">] {</span></div><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 class="m_2870938051982861869Apple-tab-span" style="white-space:pre-wrap">        </span></span><br class="m_2870938051982861869webkit-block-placeholder"></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(186,45,162)"><span style="font-variant-ligatures:no-common-ligatures;color:#000000"><span class="m_2870938051982861869Apple-tab-span" style="white-space:pre-wrap">        </span></span><span style="font-variant-ligatures:no-common-ligatures">return</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> []</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span 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"><span style="font-variant-ligatures:no-common-ligatures"></span><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures;color:#31595d">processAll</span><span style="font-variant-ligatures:no-common-ligatures">(type: </span><span style="font-variant-ligatures:no-common-ligatures;color:#4f8187">Bicycle</span><span style="font-variant-ligatures:no-common-ligatures">.</span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2">self</span><span style="font-variant-ligatures:no-common-ligatures">, in: [</span><span style="font-variant-ligatures:no-common-ligatures;color:#4f8187">Vehicle</span><span style="font-variant-ligatures:no-common-ligatures">()], condition: {</span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2">_</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2">in</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2">true</span><span style="font-variant-ligatures:no-common-ligatures">}) </span></div></div><div><div class="h5"><br><div><blockquote type="cite"><div>On Nov 21, 2016, at 8:24 PM, Ramiro Feria Purón via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_2870938051982861869Apple-interchange-newline"><div><div dir="ltr">Yes, it does; as it does <span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">let</span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures"> processedCars: [</span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">Car</span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures">] = </span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">processAll</span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures">(in: </span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">vehicles</span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures">, condition: </span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">aboveSpeedLimit</span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures">)</span><div><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures"><br></span></div><div><span style="font-variant-ligatures:no-common-ligatures"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.800000190734863px">The core of the matter is that it is nowhere stated in the call (expression) </span><span style="color:rgb(52,149,175);font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures">processAll</span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures">(in: </span><span style="color:rgb(52,149,175);font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures">ve<wbr>hicles</span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures">, condition: </span><span style="color:rgb(52,149,175);font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures">aboveSpeedLimit</span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures">) </span><span style="font-size:12.800000190734863px">th<wbr>at the specialised version </span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">processAll</span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures">&lt;</span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">Bicycle</span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures">&gt; </span><span style="font-size:12.800000190734863px">is the one to be called. </span></span></div><div><span style="font-variant-ligatures:no-common-ligatures"><span style="font-size:12.800000190734863px"><br></span></span></div><div><span style="font-variant-ligatures:no-common-ligatures"><span style="font-size:12.800000190734863px">Although we are aware of the semantics, it does not read naturally and is somehow confusing. The ultimate goal is to make swift cleaner and clear. It rather feels like invoking non-specialised, non-generic function, and then casting the result to an array of a given type, which is not the case.</span><br></span></div><div><span style="font-variant-ligatures:no-common-ligatures"><span style="font-size:12.800000190734863px"><br></span></span></div><div><span style="font-variant-ligatures:no-common-ligatures"><span style="font-size:12.800000190734863px">All the best,</span></span></div><div><span style="font-variant-ligatures:no-common-ligatures"><span style="font-size:12.800000190734863px">Ramiro</span></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-11-22 12:09 GMT+11:00 Sean Heber <span dir="ltr">&lt;<a href="mailto:sean@fifthace.com" target="_blank">sean@fifthace.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>Doesn&#39;t this work?</div><div><br></div><div>processAll(in: vehicles, condition: aboveSpeedLimit) as [Bicycle]</div><div><br></div><div>l8r</div><div>Sean</div><div><br><div>Sent from my iPad</div></div><div><div class="m_2870938051982861869h5"><div><br>On Nov 21, 2016, at 6:11 PM, Ramiro Feria Purón via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><span style="font-size:12.800000190734863px">Inferring the type of an expression from its surrounding context is not necessarily an ideal feature in a strongly typed programming language.</span><div style="font-size:12.800000190734863px"><br></div><div style="font-size:12.800000190734863px">The goal here is to be able to be explicit about the type, in an elegant and clear way, especially when there is no (need for a) context. </div><div style="font-size:12.800000190734863px"><br></div><div style="font-size:12.800000190734863px">Note that the &lt;Type&gt; &quot;noise&quot; would only be necessary when the type could not be inferred from the actual parameters (and if the current surrounding context type inference was removed, which is not part of the proposal).</div><div style="font-size:12.800000190734863px"><br></div><div style="font-size:12.800000190734863px">The line of code from the Motivation that does not compile is:</div><div style="font-size:12.800000190734863px"><br></div><div style="font-size:12.800000190734863px"><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">processAll</span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures">&lt;</span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">Bicycle</span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures">&gt;(in: </span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">vehicl<wbr>es</span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures">, condition: </span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">aboveSpeedLimit</span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures">)                       </span><span style="color:rgb(0,143,0);font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures">// This should be allowed under this proposal</span><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-11-22 10:35 GMT+11:00 Adrian Zubarev <span dir="ltr">&lt;<a href="mailto:adrian.zubarev@devandartist.com" target="_blank">adrian.zubarev@devandartist.c<wbr>om</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div class="m_2870938051982861869m_1528253077411346657m_-7327322934150946090bloop_markdown"><p>I’m not sure what are you trying to solve here. Your code from the motivation compiles just fine in my Playground.</p><p>About the <code>g</code> function:</p>

<pre><code class="m_2870938051982861869m_1528253077411346657m_-7327322934150946090swift">g(7) as [String]  
let _: [String] = g(7)
</code></pre><p>Personally I don’t like to see <code>&lt;Type&gt;</code> noise on functions in Swift.</p><div><br class="m_2870938051982861869webkit-block-placeholder"></div></div><div class="m_2870938051982861869m_1528253077411346657m_-7327322934150946090bloop_original_html"><div id="m_2870938051982861869m_1528253077411346657m_-7327322934150946090bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;margin:0px"><br></div> <br> <div id="m_2870938051982861869m_1528253077411346657m_-7327322934150946090bloop_sign_1479771201736640000" class="m_2870938051982861869m_1528253077411346657m_-7327322934150946090bloop_sign"><div style="font-family:helvetica,arial;font-size:13px">-- <br>Adrian Zubarev<br>Sent with Airmail</div></div><div><div class="m_2870938051982861869m_1528253077411346657h5"> <br><p class="m_2870938051982861869m_1528253077411346657m_-7327322934150946090airmail_on">Am 22. November 2016 um 00:06:02, Ramiro Feria Purón via swift-evolution (<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>) schrieb:</p> </div></div><blockquote type="cite" class="m_2870938051982861869m_1528253077411346657m_-7327322934150946090clean_bq"><span><div><div></div><div><div><div class="m_2870938051982861869m_1528253077411346657h5">





<div dir="ltr"><b>Problem:</b>
<div><br></div>
<div>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><br></div>
<div><div 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">f&lt;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">t:</span>
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">T</span><span style="font-variant-ligatures:no-common-ligatures">)
{</span></div><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 class="m_2870938051982861869webkit-block-placeholder"></p><div 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"> 
 </span> <span style="font-variant-ligatures:no-common-ligatures">//..</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures">}</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures"><br></span></div>
</div><div 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(52,149,175)">f</span><span style="font-variant-ligatures:no-common-ligatures">(5) 
         </span> <span style="font-variant-ligatures:no-common-ligatures">// T inferred to be
Int</span></div>
<div><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">
f</span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures">(</span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures;color:rgb(180,38,26)">&quot;xzcvzxcvx&quot;</span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures">) </span>
<span style="color:rgb(0,143,0);font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures">
// T inferred to be string</span> </div>
<div><br></div>
<div>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><br></div>
<div><div 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">g&lt;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)">Int</span><span style="font-variant-ligatures:no-common-ligatures">)
-&gt; [</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">T</span><span style="font-variant-ligatures:no-common-ligatures">]
{</span></div><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 class="m_2870938051982861869webkit-block-placeholder"></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures"> 
 </span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">var</span>
<span style="font-variant-ligatures:no-common-ligatures">result:
[</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">T</span><span style="font-variant-ligatures:no-common-ligatures">]
= []</span></div><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 class="m_2870938051982861869webkit-block-placeholder"></p><div 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"> 
 </span> <span style="font-variant-ligatures:no-common-ligatures">//..</span></div><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 class="m_2870938051982861869webkit-block-placeholder"></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures"> 
 </span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">return</span>
<span style="font-variant-ligatures:no-common-ligatures">result</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures">}</span></div>
</div>
<div><br></div>
<div>In such cases, the type parameters must be inferrable from the
context:<br></div>
<div><br></div>
<div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">g</span><span style="font-variant-ligatures:no-common-ligatures">(7) 
                 
       </span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,0)">//
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)">
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">let</span>
<span style="font-variant-ligatures:no-common-ligatures">array
=</span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">g</span><span style="font-variant-ligatures:no-common-ligatures">(7) 
             </span>
<span style="font-variant-ligatures:no-common-ligatures">// 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)">
</p><div 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)">let</span>
<span style="font-variant-ligatures:no-common-ligatures">array:
[</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">String</span><span style="font-variant-ligatures:no-common-ligatures">]
=</span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">g</span><span style="font-variant-ligatures:no-common-ligatures">(7) 
   </span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,0)">//
Ok: T inferred to be String</span></div><div 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)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">
let</span><span style="font-variant-ligatures:no-common-ligatures"> array
= </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">g</span><span style="font-variant-ligatures:no-common-ligatures">&lt;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">String</span><span style="font-variant-ligatures:no-common-ligatures">&gt;(7) 
      </span><span style="font-variant-ligatures:no-common-ligatures">// Error: Cannot
explicitly specialise generic function</span><br></span></div><div 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"><br></span></div><div 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"><br></span></div><div 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"><br></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,143,0)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small"><b>
Proposed Solution:</b></span></div>
<div><br></div>
<div>Allow explicit type parameters in generic function call:</div>
</div>
<div><br></div>
<div><div 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)">let</span>
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">_</span>
<span style="font-variant-ligatures:no-common-ligatures">=</span>
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">g</span><span style="font-variant-ligatures:no-common-ligatures">&lt;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">String</span><span style="font-variant-ligatures:no-common-ligatures">&gt;(7)
           </span><span style="color:rgb(0,143,0)">// Ok</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div style="margin:0px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures"><b style="color:rgb(34,34,34);font-family:arial,sans-serif">Motivation<span style="font-size:11px">:</span></b></span></div>
<div><br></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
</p>
<div>Consider the following contrived example:</div>
</div>
<div><br></div>
<div><div 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)">class</span>
<span style="font-variant-ligatures:no-common-ligatures">Vehicle
{</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures"> 
 </span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">var</span>
<span style="font-variant-ligatures:no-common-ligatures">currentSpeed =
0</span></div><div 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"> 
 </span> <span style="font-variant-ligatures:no-common-ligatures">//..</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span 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">
<br></div><div 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)">class</span>
<span style="font-variant-ligatures:no-common-ligatures">Bicycle:</span>
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">Vehicle</span>
<span style="font-variant-ligatures:no-common-ligatures">{</span></div><div 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"> 
 </span> <span style="font-variant-ligatures:no-common-ligatures">//..</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span 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">
<br></div><div 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)">class</span>
<span style="font-variant-ligatures:no-common-ligatures">Car:</span>
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">Vehicle</span>
<span style="font-variant-ligatures:no-common-ligatures">{</span></div><div 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"> 
 </span> <span style="font-variant-ligatures:no-common-ligatures">//..</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures">}</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(4,51,255)">
<span style="font-variant-ligatures:no-common-ligatures">@discardableResult</span></div><div 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">processAll&lt;T:</span>
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">Vehicle</span><span style="font-variant-ligatures:no-common-ligatures">&gt;(in
vehicles: [</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">Vehicle</span><span style="font-variant-ligatures:no-common-ligatures">],
condition: (</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">Vehicle</span><span style="font-variant-ligatures:no-common-ligatures">)
-&gt;</span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">Bool</span><span style="font-variant-ligatures:no-common-ligatures">)
-&gt; [</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">T</span><span style="font-variant-ligatures:no-common-ligatures">]
{</span></div><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 class="m_2870938051982861869webkit-block-placeholder"></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures"> 
 </span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">var</span>
<span style="font-variant-ligatures:no-common-ligatures">processed:
[</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">T</span><span style="font-variant-ligatures:no-common-ligatures">]
= []</span></div><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 class="m_2870938051982861869webkit-block-placeholder"></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures"> 
 </span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">for</span>
<span style="font-variant-ligatures:no-common-ligatures">vehicle</span>
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">in</span>
<span style="font-variant-ligatures:no-common-ligatures">vehicles
{</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures"> 
     </span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">guard</span>
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">let</span>
<span style="font-variant-ligatures:no-common-ligatures">t =
vehicle</span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">as</span><span style="font-variant-ligatures:no-common-ligatures">?</span>
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">T</span><span style="font-variant-ligatures:no-common-ligatures">,
condition(vehicle)</span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">else</span>
<span style="font-variant-ligatures:no-common-ligatures">{</span>
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">continue</span>
<span style="font-variant-ligatures:no-common-ligatures">}</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures"> 
     </span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,0)">//..</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures"> 
      processed.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">append</span><span style="font-variant-ligatures:no-common-ligatures">(t)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures"> 
  }</span></div><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 class="m_2870938051982861869webkit-block-placeholder"></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures"> 
 </span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">return</span>
<span style="font-variant-ligatures:no-common-ligatures">processed</span></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(4,51,255)">
</p><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures">}</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div 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">aboveSpeedLimit(vehicle:</span>
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">Vehicle</span><span style="font-variant-ligatures:no-common-ligatures">)
-&gt;</span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">Bool</span>
<span style="font-variant-ligatures:no-common-ligatures">{</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures"> 
 </span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">return</span>
<span style="font-variant-ligatures:no-common-ligatures">vehicle.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">currentSpeed</span><span style="font-variant-ligatures:no-common-ligatures"> &gt;=
100</span></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
</p><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures">}</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures"><br></span></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
</p><div 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)">let</span>
<span style="font-variant-ligatures:no-common-ligatures">processedVehicles
=</span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">processAll</span><span style="font-variant-ligatures:no-common-ligatures">(in:</span>
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">vehicles</span><span style="font-variant-ligatures:no-common-ligatures">,
condition:</span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">aboveSpeedLimit</span><span style="font-variant-ligatures:no-common-ligatures">) 
     </span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,0)">//
Uh, T inferred to be Vehicle!</span></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
</p><div 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)">let</span>
<span style="font-variant-ligatures:no-common-ligatures">processedCars:
[</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">Car</span><span style="font-variant-ligatures:no-common-ligatures">]
=</span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">processAll</span><span style="font-variant-ligatures:no-common-ligatures">(in:</span>
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">vehicles</span><span style="font-variant-ligatures:no-common-ligatures">,
condition:</span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">aboveSpeedLimit</span><span style="font-variant-ligatures:no-common-ligatures">)
   </span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,0)">//
T inferred to be Car</span></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
</p><div 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(52,149,175)">processAll</span><span style="font-variant-ligatures:no-common-ligatures">&lt;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">Bicycle</span><span style="font-variant-ligatures:no-common-ligatures">&gt;(in:</span>
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">vehicles</span><span style="font-variant-ligatures:no-common-ligatures">,
condition:</span> <span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)">aboveSpeedLimit</span><span style="font-variant-ligatures:no-common-ligatures">)
                 
   </span> <span style="font-variant-ligatures:no-common-ligatures">// This should be
allowed under this proposal</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div style="margin:0px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures"><b style="color:rgb(34,34,34);font-family:arial,sans-serif">Notes<span style="font-size:11px">:</span></b></span></div>
<div><br></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
</p>
<div>If necessary, the (real life) Swift code that lead to the
proposal could be shared.</div>
</div>
<div><br></div>
</div></div></div>


______________________________<wbr>_________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-evolution</a><br></div></div></span></blockquote></div><div class="m_2870938051982861869m_1528253077411346657m_-7327322934150946090bloop_markdown"><div><br class="m_2870938051982861869webkit-block-placeholder"></div></div></div></blockquote></div><br></div>
</div></blockquote><blockquote type="cite"><div><span>______________________________<wbr>_________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-evolution</a></span><br></div></blockquote></div></div></div></blockquote></div><br></div>
______________________________<wbr>_________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br></div></blockquote></div><br></div></div></div></blockquote></div><br></div>