<div dir="ltr"><span style="font-size:12.8px">A perfectly reasonable preference. For me, &quot;as&quot; reads as a potential type conversion (which I don&#39;t want) and specifying the type on the local can be verbose in cases when a single input or output type is sufficient for disambiguation. plus1 has 1/3 the number of types specified in the type deduction operator example than appear in the explicitly typed local or the as-cast code. Anyway, I hope you will consider all hinting/deduction techniques as alternatives to your proposal so that you can say why it&#39;s better or if it&#39;s solving a different problem.</span><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 25, 2016 at 11:43 PM, David Hart <span dir="ltr">&lt;<a href="mailto:david@hartbit.com" target="_blank">david@hartbit.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>I personally don&#39;t really see the advantage of those deduction operators. I would prefer writing:</div><div><br></div><div><div dir="ltr"><div><font color="#000000"><span style="background-color:rgba(255,255,255,0)">let plus1: (Int, Int) -&gt; Int = +</span></font></div><div><span style="background-color:rgba(255,255,255,0)">let plus2 = + as ((Int, Int) -&gt; Int)</span></div></div></div><div><div class="h5"><div><br>On 26 May 2016, at 06:11, Callionica (Swift) &lt;<a href="mailto:swift-callionica@callionica.com" target="_blank">swift-callionica@callionica.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">I have an alternative you might like to consider: type deduction operators<div><br><div>The input type deduction operator lets you put one or more types in front of a function to guide type deduction based on the parameters</div><div><br></div><div>The output type deduction operator lets you put a type after a function to guide type deduction based on the return type</div><div><br></div><div>This is a library-only solution that lets you not only select a specialization for a generic function, but also choose an overload from an overload set</div><div><br></div><div>It&#39;s up to the user whether they use input, output, or both type deduction ops and up to them how many types they supply for input. For example, when you know that the overloads or generic functions you&#39;re choosing from have two parameters of the same type, you only need to provide a single type to trigger the correct type deduction (shown below with operator+).</div><div><div><br></div><div>Here&#39;s the basic idea (the specific symbol used is just what I use, could be changed):</div><div><br></div><div>infix operator &gt;&gt;&gt; { associativity left }</div><div><br></div><div>// Input type deduction operator</div><div>func &gt;&gt;&gt; &lt;In, Out&gt;(deduce: In.Type, fn: In -&gt; Out) -&gt; In -&gt; Out {</div><div>    return fn</div><div>}</div><div><br></div><div>// Add versions for functions with 2-5 parameters</div><div>func &gt;&gt;&gt; &lt;In, In2, Out&gt;(deduce: In.Type, fn: (In, In2) -&gt; Out) -&gt; (In, In2) -&gt; Out {</div><div>    return fn</div><div>}</div><div><br></div><div>// Add versions for 2-5 inputs</div><div>func &gt;&gt;&gt; &lt;In, In2, Out&gt;(deduce: (In.Type, In2.Type), fn: (In, In2) -&gt; Out) -&gt; (In, In2) -&gt; Out {</div><div>    return fn</div><div>}</div><div><br></div><div>// Output type deduction operator</div><div>func &gt;&gt;&gt; &lt;In, Out&gt;(fn: In -&gt; Out, deduce: Out.Type) -&gt; In -&gt; Out {</div><div>    return fn</div><div>}</div><div><br></div><div>let plus1 = Int.self &gt;&gt;&gt; (+)</div><div>let plus2 = (Int.self, Int.self) &gt;&gt;&gt; (+) </div><div><br></div><div>-- Callionica</div><div><br></div><div><br></div><div><br></div><div><br><div><br></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 25, 2016 at 4:17 PM, David Hart via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hello,<div><br></div><div>This is a new pitch to allow explicitly specializing generic functions. Notice that potential ambiguity with initialisers and how I’m currently trying to avoid it. Please let me know what you think!</div><div><br></div><div>David</div><div><br></div><div><h1 style="font-size:2.25em;margin-right:0px;margin-bottom:16px;margin-left:0px;line-height:1.2;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255);margin-top:0px!important">Allow explicit specialization of generic functions</h1><ul style="padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><li>Proposal: <a href="https://github.com/apple/swift-evolution/blob/master/proposals/XXXX-allow-explicit-specialization-generic-functions.md" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" target="_blank">SE-XXXX</a></li><li>Author: <a href="https://github.com/hartbit" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" target="_blank">David Hart</a>, <a href="https://github.com/DougGregor" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" target="_blank">Douglas Gregor</a></li><li>Status: TBD</li><li>Review manager: TBD</li></ul><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)"><a href="https://github.com/hartbit/swift-evolution/tree/allow-explicit-types-generic-functions#introduction" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1" target="_blank"><u></u><u></u><u></u><u></u></a>Introduction</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">This proposal allows bypassing the type inference engine and explicitly specializing type arguments of generic functions. </p><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)"><a href="https://github.com/hartbit/swift-evolution/tree/allow-explicit-types-generic-functions#motivation" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1" target="_blank"><u></u><u></u><u></u><u></u></a>Motivation</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">In Swift, generic type parameters are inferred by the argument or return value types as follows:</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><pre style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal"><span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">foo</span>&lt;T&gt;(t: T) { <span style="color:rgb(167,29,93)">...</span> }

foo(<span style="color:rgb(0,134,179)">5</span>) <span style="color:rgb(150,152,150)">// infers T = Int</span></pre></div><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">There exists certain scenarios when a programmer wants to explicitly specialize a generic function. Swift does not allow it, so we resort to giving hints to the inference engine:</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><pre style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal"><span style="color:rgb(167,29,93)">let</span> f1 <span style="color:rgb(167,29,93)">=</span> foo <span style="color:rgb(167,29,93)">as</span> ((<span style="color:rgb(0,134,179)">Int</span>) <span style="color:rgb(167,29,93)">-&gt;</span> <span style="color:rgb(0,134,179)">Void</span>)
<span style="color:rgb(167,29,93)">let</span> f2: (<span style="color:rgb(0,134,179)">Int</span>) <span style="color:rgb(167,29,93)">-&gt;</span> <span style="color:rgb(0,134,179)">Void</span> <span style="color:rgb(167,29,93)">=</span> foo
<span style="color:rgb(167,29,93)">let</span> f3 <span style="color:rgb(167,29,93)">=</span> foo<span style="color:rgb(167,29,93)">&lt;</span><span style="color:rgb(0,134,179)">Int</span><span style="color:rgb(167,29,93)">&gt;</span> <span style="color:rgb(150,152,150)">// error: Cannot explicitly specialize a generic function</span>

<span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">bar</span>&lt;T&gt;() <span style="color:rgb(167,29,93)">-&gt;</span> T { <span style="color:rgb(167,29,93)">...</span> }

<span style="color:rgb(167,29,93)">let</span> b1 <span style="color:rgb(167,29,93)">=</span> bar() <span style="color:rgb(167,29,93)">as</span> <span style="color:rgb(0,134,179)">Int</span>
<span style="color:rgb(167,29,93)">let</span> b2: <span style="color:rgb(0,134,179)">Int</span> <span style="color:rgb(167,29,93)">=</span> bar()
<span style="color:rgb(167,29,93)">let</span> b3 <span style="color:rgb(167,29,93)">=</span> bar<span style="color:rgb(167,29,93)">&lt;</span><span style="color:rgb(0,134,179)">Int</span><span style="color:rgb(167,29,93)">&gt;</span>() <span style="color:rgb(150,152,150)">// error: Cannot explicitly specialize a generic function</span></pre></div><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">This behaviour is not very consistent with generic types which allow specialization:</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><pre style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal"><span style="color:rgb(167,29,93)">let</span> array: <span style="color:rgb(0,134,179)">Array</span><span style="color:rgb(167,29,93)">&lt;</span><span style="color:rgb(0,134,179)">Int</span><span style="color:rgb(167,29,93)">&gt;</span> <span style="color:rgb(167,29,93)">=</span> <span style="color:rgb(0,134,179)">Array</span><span style="color:rgb(167,29,93)">&lt;</span><span style="color:rgb(0,134,179)">Int</span><span style="color:rgb(167,29,93)">&gt;</span>(arrayLiteral: <span style="color:rgb(0,134,179)">1</span>, <span style="color:rgb(0,134,179)">2</span>, <span style="color:rgb(0,134,179)">3</span>)</pre></div><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">Therefore, this proposal seeks to make the above errors valid specializations:</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><pre style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal"><span style="color:rgb(167,29,93)">let</span> f3 <span style="color:rgb(167,29,93)">=</span> foo<span style="color:rgb(167,29,93)">&lt;</span><span style="color:rgb(0,134,179)">Int</span><span style="color:rgb(167,29,93)">&gt;</span> <span style="color:rgb(150,152,150)">// explicitly specialized to (Int) -&gt; Void </span>
<span style="color:rgb(167,29,93)">let</span> b3 <span style="color:rgb(167,29,93)">=</span> bar<span style="color:rgb(167,29,93)">&lt;</span><span style="color:rgb(0,134,179)">Int</span><span style="color:rgb(167,29,93)">&gt;</span>() <span style="color:rgb(150,152,150)">// explicitly specialized to () -&gt; Int </span></pre></div><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">An ambiguous scenario arrises when we wish to specialize initializer functions:</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><pre style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal"><span style="color:rgb(167,29,93)">struct</span> Foo<span style="color:rgb(167,29,93)">&lt;</span>T: <span style="color:rgb(0,134,179)">RawRepresentable</span> <span style="color:rgb(167,29,93)">where</span> T<span style="color:rgb(167,29,93)">.</span>RawValue <span style="color:rgb(167,29,93)">==</span> <span style="color:rgb(0,134,179)">String</span><span style="color:rgb(167,29,93)">&gt;</span> {
    <span style="color:rgb(167,29,93)">let</span> storage: T

    <span style="color:rgb(167,29,93)">init</span><span style="color:rgb(167,29,93)">&lt;</span>U: <span style="color:rgb(0,134,179)">CustomStringConvertible</span><span style="color:rgb(167,29,93)">&gt;</span>(_ value: U) {
        storage <span style="color:rgb(167,29,93)">=</span> T(rawValue: value<span style="color:rgb(167,29,93)">.</span><span style="color:rgb(0,134,179)">description</span>)<span style="color:rgb(167,29,93)">!</span>
    }
}

<span style="color:rgb(167,29,93)">enum</span> Bar: <span style="color:rgb(0,134,179)">String</span>, <span style="color:rgb(0,134,179)">CustomStringConvertible</span> {
    <span style="color:rgb(167,29,93)">case</span> foobar <span style="color:rgb(167,29,93)">=</span> <span style="color:rgb(24,54,145)"><span>&quot;</span>foo<span>&quot;</span></span>

    <span style="color:rgb(167,29,93)">var</span> description: <span style="color:rgb(0,134,179)">String</span> {
        <span style="color:rgb(167,29,93)">return</span> <span style="color:rgb(167,29,93)">self</span><span style="color:rgb(167,29,93)">.</span><span style="color:rgb(0,134,179)">rawValue</span>
    }
}

<span style="color:rgb(167,29,93)">let</span> a <span style="color:rgb(167,29,93)">=</span> Foo<span style="color:rgb(167,29,93)">&lt;</span>Bar<span style="color:rgb(167,29,93)">&gt;</span>(Bar<span style="color:rgb(167,29,93)">.</span>foobar)</pre></div><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">Does this specialization specialize the struct&#39;s or the initializer&#39;s generic type? The proposal solves this ambiguity by requiring initializer generic type specialization to use the <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">init</code> syntax:</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><pre style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal"><span style="color:rgb(167,29,93)">let</span> a <span style="color:rgb(167,29,93)">=</span> Foo<span style="color:rgb(167,29,93)">&lt;</span>Bar<span style="color:rgb(167,29,93)">&gt;.</span><span style="color:rgb(167,29,93)">init</span><span style="color:rgb(167,29,93)">&lt;</span>Bar<span style="color:rgb(167,29,93)">&gt;</span>(Bar<span style="color:rgb(167,29,93)">.</span>foobar)</pre></div><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)"><a href="https://github.com/hartbit/swift-evolution/tree/allow-explicit-types-generic-functions#detailed-design" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1" target="_blank"><u></u><u></u><u></u><u></u></a>Detailed Design</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">Function calls are fairly straight forward and have their grammar modified as follows:</p><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><em>function-call-expression</em> → <em>postfix-expression­</em> <em>generic-argument-clause<span style="font-size:12px;line-height:0;vertical-align:baseline">­opt</span></em> <em>parenthesized-expression</em></p><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><em>function-call-expression</em> → <em>postfix-expression</em> <em>generic-argument-clause<span style="font-size:12px;line-height:0;vertical-align:baseline">­opt</span></em> <em>­parenthesized-expression<span style="font-size:12px;line-height:0;vertical-align:baseline">­opt</span></em> <em>­trailing-closure­</em></p><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">To allow initializers to be called with explicit specialization, we need to use the Initializer Expression. Its grammar is modified to:</p><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><em>initializer-expression</em> → <em>postfix-expression­</em> <span>.</span> <em>­init­</em> <em>generic-argument-clause<span style="font-size:12px;line-height:0;vertical-align:baseline">­opt</span></em></p><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><em>initializer-expression</em> → <em>postfix-expression­</em> <span>.</span> <em>­init­</em> <em>generic-argument-clause<span style="font-size:12px;line-height:0;vertical-align:baseline">­opt</span></em> <span>(</span> <em>­argument-names­</em> <span>)</span></p><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)"><a href="https://github.com/hartbit/swift-evolution/tree/allow-explicit-types-generic-functions#impact-on-existing-code" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1" target="_blank"><u></u><u></u><u></u><u></u></a>Impact on Existing Code</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">This proposal is purely additive and will have no impact on existing code.</p><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)"><a href="https://github.com/hartbit/swift-evolution/tree/allow-explicit-types-generic-functions#alternatives-considered" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1" target="_blank"><u></u><u></u><u></u><u></u></a>Alternatives Considered</h2><div style="margin-top:0px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255);margin-bottom:0px!important">Not adopting this proposal for Swift.</div></div></div><br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div>
</div></blockquote></div></div></div></blockquote></div><br></div>