<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=""><div class="">Sounds good :) I’ll mention those in the Alternatives.</div><br class=""><div><blockquote type="cite" class=""><div class="">On 26 May 2016, at 09:26, Callionica &lt;<a href="mailto:cloud.google@callionica.com" class="">cloud.google@callionica.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class=""></div><div class="">A perfectly reasonable preference. For me, "as" reads as a potential type conversion (which I don'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's better or if it's solving a different problem.</div><div class=""><br class=""></div><div class="">-- Callionica</div><div class=""><br class="">On May 25, 2016, at 11:43 PM, David Hart &lt;<a href="mailto:david@hartbit.com" class="">david@hartbit.com</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div class="">I personally don't really see the advantage of those deduction operators. I would prefer writing:</div><div class=""><br class=""></div><div class=""><div dir="ltr" class=""><div class=""><font class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">let plus1: (Int, Int) -&gt; Int = +</span></font></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">let plus2 = + as ((Int, Int) -&gt; Int)</span></div></div></div><div class=""><br class="">On 26 May 2016, at 06:11, Callionica (Swift) &lt;<a href="mailto:swift-callionica@callionica.com" class="">swift-callionica@callionica.com</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class="">I have an alternative you might like to consider: type deduction operators<div class=""><br class=""><div class="">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 class=""><br class=""></div><div class="">The output type deduction operator lets you put a type after a function to guide type deduction based on the return type</div><div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">It'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'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 class=""><div class=""><br class=""></div><div class="">Here's the basic idea (the specific symbol used is just what I use, could be changed):</div><div class=""><br class=""></div><div class="">infix operator &gt;&gt;&gt; { associativity left }</div><div class=""><br class=""></div><div class="">// Input type deduction operator</div><div class="">func &gt;&gt;&gt; &lt;In, Out&gt;(deduce: In.Type, fn: In -&gt; Out) -&gt; In -&gt; Out {</div><div class="">&nbsp; &nbsp; return fn</div><div class="">}</div><div class=""><br class=""></div><div class="">// Add versions for functions with 2-5 parameters</div><div class="">func &gt;&gt;&gt; &lt;In, In2, Out&gt;(deduce: In.Type, fn: (In, In2) -&gt; Out) -&gt; (In, In2) -&gt; Out {</div><div class="">&nbsp; &nbsp; return fn</div><div class="">}</div><div class=""><br class=""></div><div class="">// Add versions for 2-5 inputs</div><div class="">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 class="">&nbsp; &nbsp; return fn</div><div class="">}</div><div class=""><br class=""></div><div class="">// Output type deduction operator</div><div class="">func &gt;&gt;&gt; &lt;In, Out&gt;(fn: In -&gt; Out, deduce: Out.Type) -&gt; In -&gt; Out {</div><div class="">&nbsp; &nbsp; return fn</div><div class="">}</div><div class=""><br class=""></div><div class="">let plus1 = Int.self &gt;&gt;&gt; (+)</div><div class="">let plus2 = (Int.self, Int.self) &gt;&gt;&gt; (+)&nbsp;</div><div class=""><br class=""></div><div class="">-- Callionica</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""><div class=""><br class=""></div></div></div></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, May 25, 2016 at 4:17 PM, David Hart via swift-evolution <span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Hello,<div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">David</div><div class=""><br class=""></div><div class=""><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:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';background-color:rgb(255,255,255);margin-top:0px!important" class="">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:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class=""><li class="">Proposal:&nbsp;<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" class="">SE-XXXX</a></li><li class="">Author:&nbsp;<a href="https://github.com/hartbit" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" target="_blank" class="">David Hart</a>,&nbsp;<a href="https://github.com/DougGregor" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" target="_blank" class="">Douglas Gregor</a></li><li class="">Status: TBD</li><li class="">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:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';background-color:rgb(255,255,255)" class=""><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" class=""><u class=""></u><u class=""></u><u class=""></u><u class=""></u></a>Introduction</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="">This proposal allows bypassing the type inference engine and explicitly specializing type arguments of generic functions.&nbsp;</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:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';background-color:rgb(255,255,255)" class=""><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" class=""><u class=""></u><u class=""></u><u class=""></u><u class=""></u></a>Motivation</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="">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:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class=""><pre style="font-family:Consolas,'Liberation Mono',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" class=""><span style="color:rgb(167,29,93)" class="">func</span> <span style="color:rgb(121,93,163)" class="">foo</span>&lt;T&gt;(t: T) { <span style="color:rgb(167,29,93)" class="">...</span> }

foo(<span style="color:rgb(0,134,179)" class="">5</span>) <span style="color:rgb(150,152,150)" class="">// infers T = Int</span></pre></div><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="">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:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class=""><pre style="font-family:Consolas,'Liberation Mono',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" class=""><span style="color:rgb(167,29,93)" class="">let</span> f1 <span style="color:rgb(167,29,93)" class="">=</span> foo <span style="color:rgb(167,29,93)" class="">as</span> ((<span style="color:rgb(0,134,179)" class="">Int</span>) <span style="color:rgb(167,29,93)" class="">-&gt;</span> <span style="color:rgb(0,134,179)" class="">Void</span>)
<span style="color:rgb(167,29,93)" class="">let</span> f2: (<span style="color:rgb(0,134,179)" class="">Int</span>) <span style="color:rgb(167,29,93)" class="">-&gt;</span> <span style="color:rgb(0,134,179)" class="">Void</span> <span style="color:rgb(167,29,93)" class="">=</span> foo
<span style="color:rgb(167,29,93)" class="">let</span> f3 <span style="color:rgb(167,29,93)" class="">=</span> foo<span style="color:rgb(167,29,93)" class="">&lt;</span><span style="color:rgb(0,134,179)" class="">Int</span><span style="color:rgb(167,29,93)" class="">&gt;</span> <span style="color:rgb(150,152,150)" class="">// error: Cannot explicitly specialize a generic function</span>

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

<span style="color:rgb(167,29,93)" class="">let</span> b1 <span style="color:rgb(167,29,93)" class="">=</span> bar() <span style="color:rgb(167,29,93)" class="">as</span> <span style="color:rgb(0,134,179)" class="">Int</span>
<span style="color:rgb(167,29,93)" class="">let</span> b2: <span style="color:rgb(0,134,179)" class="">Int</span> <span style="color:rgb(167,29,93)" class="">=</span> bar()
<span style="color:rgb(167,29,93)" class="">let</span> b3 <span style="color:rgb(167,29,93)" class="">=</span> bar<span style="color:rgb(167,29,93)" class="">&lt;</span><span style="color:rgb(0,134,179)" class="">Int</span><span style="color:rgb(167,29,93)" class="">&gt;</span>() <span style="color:rgb(150,152,150)" class="">// 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:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="">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:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class=""><pre style="font-family:Consolas,'Liberation Mono',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" class=""><span style="color:rgb(167,29,93)" class="">let</span> array: <span style="color:rgb(0,134,179)" class="">Array</span><span style="color:rgb(167,29,93)" class="">&lt;</span><span style="color:rgb(0,134,179)" class="">Int</span><span style="color:rgb(167,29,93)" class="">&gt;</span> <span style="color:rgb(167,29,93)" class="">=</span> <span style="color:rgb(0,134,179)" class="">Array</span><span style="color:rgb(167,29,93)" class="">&lt;</span><span style="color:rgb(0,134,179)" class="">Int</span><span style="color:rgb(167,29,93)" class="">&gt;</span>(arrayLiteral: <span style="color:rgb(0,134,179)" class="">1</span>, <span style="color:rgb(0,134,179)" class="">2</span>, <span style="color:rgb(0,134,179)" class="">3</span>)</pre></div><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="">Therefore, this proposal seeks to make the above errors valid specializations:</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class=""><pre style="font-family:Consolas,'Liberation Mono',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" class=""><span style="color:rgb(167,29,93)" class="">let</span> f3 <span style="color:rgb(167,29,93)" class="">=</span> foo<span style="color:rgb(167,29,93)" class="">&lt;</span><span style="color:rgb(0,134,179)" class="">Int</span><span style="color:rgb(167,29,93)" class="">&gt;</span> <span style="color:rgb(150,152,150)" class="">// explicitly specialized to (Int) -&gt; Void </span>
<span style="color:rgb(167,29,93)" class="">let</span> b3 <span style="color:rgb(167,29,93)" class="">=</span> bar<span style="color:rgb(167,29,93)" class="">&lt;</span><span style="color:rgb(0,134,179)" class="">Int</span><span style="color:rgb(167,29,93)" class="">&gt;</span>() <span style="color:rgb(150,152,150)" class="">// explicitly specialized to () -&gt; Int </span></pre></div><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="">An ambiguous scenario arrises when we wish to specialize initializer functions:</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class=""><pre style="font-family:Consolas,'Liberation Mono',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" class=""><span style="color:rgb(167,29,93)" class="">struct</span> Foo<span style="color:rgb(167,29,93)" class="">&lt;</span>T: <span style="color:rgb(0,134,179)" class="">RawRepresentable</span> <span style="color:rgb(167,29,93)" class="">where</span> T<span style="color:rgb(167,29,93)" class="">.</span>RawValue <span style="color:rgb(167,29,93)" class="">==</span> <span style="color:rgb(0,134,179)" class="">String</span><span style="color:rgb(167,29,93)" class="">&gt;</span> {
    <span style="color:rgb(167,29,93)" class="">let</span> storage: T

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

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

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

<span style="color:rgb(167,29,93)" class="">let</span> a <span style="color:rgb(167,29,93)" class="">=</span> Foo<span style="color:rgb(167,29,93)" class="">&lt;</span>Bar<span style="color:rgb(167,29,93)" class="">&gt;</span>(Bar<span style="color:rgb(167,29,93)" class="">.</span>foobar)</pre></div><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="">Does this specialization specialize the struct's or the initializer's generic type? The proposal solves this ambiguity by requiring initializer generic type specialization to use the&nbsp;<code style="font-family:Consolas,'Liberation Mono',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" class="">init</code>&nbsp;syntax:</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class=""><pre style="font-family:Consolas,'Liberation Mono',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" class=""><span style="color:rgb(167,29,93)" class="">let</span> a <span style="color:rgb(167,29,93)" class="">=</span> Foo<span style="color:rgb(167,29,93)" class="">&lt;</span>Bar<span style="color:rgb(167,29,93)" class="">&gt;.</span><span style="color:rgb(167,29,93)" class="">init</span><span style="color:rgb(167,29,93)" class="">&lt;</span>Bar<span style="color:rgb(167,29,93)" class="">&gt;</span>(Bar<span style="color:rgb(167,29,93)" class="">.</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:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';background-color:rgb(255,255,255)" class=""><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" class=""><u class=""></u><u class=""></u><u class=""></u><u class=""></u></a>Detailed Design</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="">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:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class=""><em class="">function-call-expression</em>&nbsp;→&nbsp;<em class="">postfix-expression­</em>&nbsp;<em class="">generic-argument-clause<span style="font-size:12px;line-height:0;vertical-align:baseline" class="">­opt</span></em>&nbsp;<em class="">parenthesized-expression</em></p><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class=""><em class="">function-call-expression</em>&nbsp;→&nbsp;<em class="">postfix-expression</em>&nbsp;<em class="">generic-argument-clause<span style="font-size:12px;line-height:0;vertical-align:baseline" class="">­opt</span></em>&nbsp;<em class="">­parenthesized-expression<span style="font-size:12px;line-height:0;vertical-align:baseline" class="">­opt</span></em>&nbsp;<em class="">­trailing-closure­</em></p><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="">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:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class=""><em class="">initializer-expression</em>&nbsp;→&nbsp;<em class="">postfix-expression­</em>&nbsp;<span class="">.</span>&nbsp;<em class="">­init­</em>&nbsp;<em class="">generic-argument-clause<span style="font-size:12px;line-height:0;vertical-align:baseline" class="">­opt</span></em></p><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class=""><em class="">initializer-expression</em>&nbsp;→&nbsp;<em class="">postfix-expression­</em>&nbsp;<span class="">.</span>&nbsp;<em class="">­init­</em>&nbsp;<em class="">generic-argument-clause<span style="font-size:12px;line-height:0;vertical-align:baseline" class="">­opt</span></em>&nbsp;<span class="">(</span>&nbsp;<em class="">­argument-names­</em>&nbsp;<span class="">)</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:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';background-color:rgb(255,255,255)" class=""><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" class=""><u class=""></u><u class=""></u><u class=""></u><u class=""></u></a>Impact on Existing Code</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="">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:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';background-color:rgb(255,255,255)" class=""><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" class=""><u class=""></u><u class=""></u><u class=""></u><u class=""></u></a>Alternatives Considered</h2><div style="margin-top:0px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255);margin-bottom:0px!important" class="">Not adopting this proposal for Swift.</div></div></div><br class="">_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class=""></blockquote></div><br class=""></div>
</div></blockquote></div></blockquote></div></div></blockquote></div><br class=""></body></html>