<div dir="ltr">I am not sure that I see the value in *not* explicitly passing those parameters on in a call, then. Needing to l keep track of the parameter list to pass on to an admittedly different method seems *too* implicit. <div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 11, 2016 at 12:17 PM, Matthew Johnson <span dir="ltr">&lt;<a href="mailto:matthew@anandabits.com" target="_blank">matthew@anandabits.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 style="word-wrap:break-word"><br><div><span class=""><blockquote type="cite"><div>On Jan 11, 2016, at 11:13 AM, T.J. Usiyan &lt;<a href="mailto:griotspeak@gmail.com" target="_blank">griotspeak@gmail.com</a>&gt; wrote:</div><br><div><div dir="ltr">The last bit might not but default values have *everything* to do with parameter forwarding. What do default values afford us in our API?<div><br></div><div>foo()</div><div>foo(first: Int)</div><div>foo(first: Int, second: String)</div><div><br></div><div>with &#39;one&#39; implementation. </div><div><br></div><div>What does parameter forwarding get us?</div><div><div><br></div></div><div><div>foo()</div><div>foo(first: Int)</div><div>foo(first: Int, second: String)</div></div><div><br></div><div>with &#39;one&#39; implementation (but maybe in reverse?)</div></div></div></blockquote><div><br></div></span><div>No, that is not the point of parameter forwarding.  Obviously default values are much better in that case.  Parameter forwarding is for use cases where you need to forward to an entirely different function.  Here are the use cases I listed in the proposal:</div><div><br></div><div><div><span style="white-space:pre-wrap">        </span>• Convenience initializers that foward parameters directly to a designated initializer<br></div><span class=""><div><span style="white-space:pre-wrap">        </span>• Designated initializers that foward parameters directly to a super initializer<br></div><div><span style="white-space:pre-wrap">        </span>• Designated initializers that foward parameters directly to a member initializer, perhaps in a composition-based design<br></div><div><span style="white-space:pre-wrap">        </span>• If the partial initilaizer proposal is accepted, designated initializers that forward parameters to one or more partial initializers</div></span></div><div><br></div><div>None of these use cases are handled by simple default values.</div><div><br></div><div>There are use cases, I just haven’t had time to put together a more comprehensive motivation section yet.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Matthew</div></font></span><div><div class="h5"><br><blockquote type="cite"><div><div dir="ltr"><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 11, 2016 at 11:15 AM, Matthew Johnson <span dir="ltr">&lt;<a href="mailto:matthew@anandabits.com" target="_blank">matthew@anandabits.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 style="word-wrap:break-word">This example doesn’t have anything to do with forwarding.  Do you have something in mind in the context of parameter forwarding?<span><font color="#888888"><div><br></div></font></span><div><span><font color="#888888">Matthew</font></span><div><div><br><div><br><div><blockquote type="cite"><div>On Jan 11, 2016, at 10:12 AM, T.J. Usiyan &lt;<a href="mailto:griotspeak@gmail.com" target="_blank">griotspeak@gmail.com</a>&gt; wrote:</div><br><div><div dir="ltr"><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:rgb(187,44,162)">func</span> _computeLastParam() -&gt; <span style="color:rgb(112,61,170)">String</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(209,47,27)"><span>    </span><span style="color:rgb(187,44,162)">return</span><span> </span>&quot;I am the last of my line&quot;</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</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="color:rgb(187,44,162)">func</span> foo(first: <span style="color:rgb(112,61,170)">Int</span>, second: <span style="color:rgb(112,61,170)">String</span>, last: <span style="color:rgb(112,61,170)">String</span> = <span style="color:rgb(49,89,93)">_computeLastParam</span>()) {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">    <span style="color:rgb(61,29,129)">print</span>(<span style="color:rgb(209,47,27)">&quot;first:</span>\<span style="color:rgb(209,47,27)">(</span>first<span style="color:rgb(209,47,27)">)&quot;</span>)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">    <span style="color:rgb(61,29,129)">print</span>(<span style="color:rgb(209,47,27)">&quot;second:</span>\<span style="color:rgb(209,47,27)">(</span>second<span style="color:rgb(209,47,27)">)&quot;</span>)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">    <span style="color:rgb(61,29,129)">print</span>(<span style="color:rgb(209,47,27)">&quot;last:</span>\<span style="color:rgb(209,47,27)">(</span>last<span style="color:rgb(209,47,27)">)&quot;</span>)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</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="color:rgb(49,89,93)">foo</span>(<span style="color:rgb(39,42,216)">1</span>, second: <span style="color:rgb(209,47,27)">&quot;two!&quot;</span>)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">&quot;</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><b>first:1</b></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><b>second:two!</b></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><b>last:I am the last of my line</b></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">&quot;</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;min-height:13px"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)">// hopefully?</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">constexpr <span style="color:rgb(187,44,162)">func</span> _computeLastParam(input: <span style="color:rgb(112,61,170)">Int</span>) -&gt; <span style="color:rgb(112,61,170)">String</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(209,47,27)"><span>    </span><span style="color:rgb(187,44,162)">return</span><span> </span>&quot;I am the last of my line and you gave me <span>\</span>(<span>input</span>)&quot;</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</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="color:rgb(187,44,162)">func</span> foo(first: <span style="color:rgb(112,61,170)">Int</span>, second: <span style="color:rgb(112,61,170)">String</span>, last: <span style="color:rgb(112,61,170)">String</span> = _computeLastParam(first)) {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">    <span style="color:rgb(61,29,129)">print</span>(<span style="color:rgb(209,47,27)">&quot;first:</span>\<span style="color:rgb(209,47,27)">(</span>first<span style="color:rgb(209,47,27)">)&quot;</span>)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">    <span style="color:rgb(61,29,129)">print</span>(<span style="color:rgb(209,47,27)">&quot;second:</span>\<span style="color:rgb(209,47,27)">(</span>second<span style="color:rgb(209,47,27)">)&quot;</span>)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">    <span style="color:rgb(61,29,129)">print</span>(<span style="color:rgb(209,47,27)">&quot;last:</span>\<span style="color:rgb(209,47,27)">(</span>last<span style="color:rgb(209,47,27)">)&quot;</span>)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</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="color:rgb(49,89,93)">foo</span>(<span style="color:rgb(39,42,216)">1</span>, second: <span style="color:rgb(209,47,27)">&quot;two!&quot;</span>)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">&quot;</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><b>first:1</b></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><b>second:two!</b></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><b>last:I am the last of my line and you gave me 1</b></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">&quot;</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 11, 2016 at 11:05 AM, Matthew Johnson <span dir="ltr">&lt;<a href="mailto:matthew@anandabits.com" target="_blank">matthew@anandabits.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 style="word-wrap:break-word"><br><div><span><blockquote type="cite"><div>On Jan 11, 2016, at 10:03 AM, T.J. Usiyan &lt;<a href="mailto:griotspeak@gmail.com" target="_blank">griotspeak@gmail.com</a>&gt; wrote:</div><br><div><div dir="ltr">I can&#39;t get behind this feature. Beside the lack of payoff for added syntax, the biggest problem is that this is mostly handled by default values. If we had (once we get?) constant expressions, I imagine that we might even be able to reference other parameters in default value method calls–which seems like a more generally useful fix for the issue.</div></div></blockquote><div><br></div></span>How is this handled by default values?  What you’re saying doesn’t make sense to me.  Can you provide an example of what you have in mind?</div><div><br></div><div>Have you used a language with a similar feature?  Did you not find it useful?</div><span><font color="#888888"><div><br></div><div>Matthew</div></font></span><div><div><div><br><blockquote type="cite"><div><div dir="ltr"><div><br></div><div>TJ</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 11, 2016 at 10:29 AM, Matthew Johnson 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"><br><div><span><blockquote type="cite"><div>On Jan 10, 2016, at 10:17 PM, Félix Cloutier &lt;<a href="mailto:felixcca@yahoo.ca" target="_blank">felixcca@yahoo.ca</a>&gt; wrote:</div><br><div><div style="word-wrap:break-word">I was okay with memberwise initializers but this pushes me beyond my comfort zone.</div></div></blockquote><div><br></div></span><div>Hi Felix, can you elaborate on why?  This feature is quite similar to features in other languages that are generally considered to be quite useful.</div><div><br></div><div>For example, most dynamic languages have the ability to pack arguments.  There has been discussion of adding tuple packing and unpacking to Swift but it wouldn’t offer everything it does in dynamic languages (as far as I can tell).</div><div><br></div><div>Swift is statically typed so we would have to specify a type for the tuple to pack / unpack.  This means it must be a fixed list of arguments.  This is not the case in dynamic languages, where whatever arguments the caller provides are forwarded.</div><div><br></div><div>Also, because the packed tuple parameter is declared manually, there would not be a way to forward a default argument value for specific members of the tuple as far as I can see (I think a default would need to be specified for the entire tuple, not just specific members).  Even if there were a way to specify a value for specific members, I don’t believe it would be possible to “forward” the default value specified by the receiving function, which is actually what is desired.  In dynamic languages, callers can just provide a subset of the tuple arguments and the receiving function detects missing arguments, filling in a default.</div><div><br></div><div>Another example is variadic generics in C++, which can also forward an arbitrary set of arguments to a receiving function.  This feature of C++ relies on the fact that the body of a template is not checked until it is expanded.  This allows the caller of the forwarding function to supply any set of parameters that would be valid when calling the forwardee.  </div><div><br></div><div>Even if Swift supported variadic generics I don’t think this method of forwarding fits the language as the body of a generic function is checked on its own.  I don’t believe there would be a way to specify constraints that would allow the arguments to be used to call the forwarding function (I may be wrong about that if a new kind of constraint was introduced to support this in the future).</div><div><br></div><div>The forwarding mechanism in this proposal supports a couple of things that I think will be quite useful which are not possible under the examples of tuple packing and unpacking in Swift that I have seen shared thus far:</div><div><br></div><div>1. Providing default values for specific parameters, not just a whole packed tuple</div><div>2. Forwarding default parameter values from the forwardee function for said parameters</div><div>3. Forwarding a subset of the forwarded’s parameters</div><div>4. Explicitly providing default values for disambiguation and to suppress forwarding of specific parameters where the callee provides a default value</div><div>5. Forwarding generic parameters</div><span><br><blockquote type="cite"><div><div style="word-wrap:break-word"><div><br></div><div>I&#39;m not sold on the usefulness of the feature. Memberwise initializers save you from typing out the init parameters and assignments to each field. Argument forwarding saves you from spelling out the parameters *more than once* (because you still need to type them out for the receiving function) and from *one call*. While I&#39;ve been annoyed at initializers, I don&#39;t think I&#39;ve ever been particularly annoyed at forwarding functions.</div></div></div></blockquote><div><br></div></span><div>Both features save approximately the same amount of code.  They save explicit declaration of parameters as well as a single action with the provided argument.</div><div><br></div><div>More importantly, forwarding is a general purpose feature that when combined with partial initializers and property lists can support much more expressive memberwise initialization than contained in the initial proposal.  There was quite a bit of discussion about both the limitations of the memberwise initialization proposal as well as the specificity of it to exactly one use case (memberwise initialization).  Forwarding plays a role in removing the limitations while building on a more general foundation.</div><div><br></div><div>Here’s an example that takes advantage of the combined power of the three proposals I just posted:</div><div><br></div><div>struct S {</div><div>  var name: String = “&quot;</div><div>  private let x, y, z: Int</div><div><br></div><div>  propertylist args: left x = 0, top y = 0, name</div><div><br></div><div>  init(…args) { z = 0 }</div><div>}</div><div><br></div><div>This does several things not possible in the current memberwise init proposal:</div><div><br></div><div>1. Supports an arbitrary subset of members</div><div>2. Supports an arbitrary order for memberwise parameters</div><div>3. Supports arbitrary labels for memberwise parameters</div><div>4. Supports arbitrary default values for parameters, including `let` properties</div><div>5. Allows more-private properties to be exposed by more-public initializer</div><div><br></div><div>Here’s how it works: </div><div><br></div><div>1. The `propertylist` declaration introduces a partial memberwise initializer corresponding to the properties specified (it also gives you a computed tuple property containing the specified properties).</div><div>2. The `…args` placeholder causes the primary initializer to forward arguments to the partial initializer introduced in step 1.</div><div><br></div><div>The equivalent manually written code would look like this (assuming partial initializers and omitting the  `args` tuple property that would be synthesized):</div><div><br></div><div><div>struct S {</div><div>  var name: String = “&quot;</div><div>  private let x, y, z: Int</div><div><br></div><div>  partial init args(left x: Int = 0, top y: Int = 0, name: String = “”) {</div><div>    self.x = x</div><div>    self.y = y</div><div>    <a href="http://self.name/" target="_blank">self.name</a> = name</div><div>  }</div><div><br></div><div>  init(left x: Int = 0, top y: Int = 0, name: String = “”) {</div><div>    args.init(left: x, top: y, name: name)</div><div>    z = 0 </div><div>  }</div><div>}</div></div><div><br></div><div>These features work together to support the additional desired use cases for memberwise initialization while remaining concise and arguably more clear (because the property list explicitly states which members participate in the memberwise partial initializer).  </div><div><br></div><div>Because the features supporting this are general we also gain:</div><div><br></div><div>1. Forwarding in any function, not just initializers (but including concise forwarding of parameters to a super or member initializer, or forwarding from a convenience initializer that just needs to provide a few direct arguments to the designated initializer and forward the rest).</div><div>2. Partial initialization support for shared, but non-memberwise initialization logic</div><div>3. Computed tuple properties for each propertylist.  (and possibly additional memberwise features in the future if we identify any that would also be generally useful)</div><div><br></div><div>In my opinion this is a huge win for both initialization as well as other parts of our code that might take advantage of these features.</div><span><br><blockquote type="cite"><div><div style="word-wrap:break-word"><div><br></div><div>I&#39;ll let the parser guys say if it&#39;s a lot of work to implement or not, but if I allow myself to speak outside of my expertise, I imagine that it&#39;s gonna be a lot more work than memberwise initializers because this requires inspecting the function body to figure out its parameters.</div></div></div></blockquote><div><br></div></span><div>It is a bit more work, sure.  It requires matching the explicitly provided arguments with the parameter list of any callee overloads that are in scope and determining whether: </div><div><br></div><div>1. There are no overloads for which the provided arguments could be part of a valid call.  Compiler error.</div><div>2. There is a single overload for which the provided arguments could be part of a valid call.  Forward the remaining arguments.</div><div>3. There are more than one overloads for which the provided arguments could be part of a valid call.  Compiler error due to ambiguity.</div><div><br></div><div>If we want a forwarding mechanism capable of forwarding default argument values, and possibly (but very desirable IMO) a subset of parameters there is no way to avoid this logic.  I am not an expert at the implementation of such features, but I don’t think it is excessively complex next to other logic implemented in the compiler.</div><span><br><blockquote type="cite"><div><div style="word-wrap:break-word"><div><br></div><div>At this point, I feel that a competent macro system is a better investment than adding distinct bits of automation wherever there appears to be repetition.<br></div></div></div></blockquote><div><br></div></span><div>I agree that a macro system would be great, but it is explicitly not in scope for Swift 3.  It would also not be capable of implementing parameter forwarding as described in this proposal.</div><div><br></div><div>I hope you will consider discussing this further.</div><div><br></div><div>Matthew</div><div><div><br><blockquote type="cite"><div><div style="word-wrap:break-word"><div><div>
<br><span style="font-family:&#39;Lucida Grande&#39;;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">Félix</span>
</div>

<br><div><blockquote type="cite"><div>Le 10 janv. 2016 à 22:44:36, Matthew Johnson via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; a écrit :</div><br><div><div style="word-wrap:break-word"><div>I have always considered the Flexible Memberwise Initialization proposal to be just a first step (as evidenced by the many future enhancements it discussed).  Its review has inspired new ideas and helped to shape my vision of the best long-term solution.  My final thoughts about the review can be found here: <a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160104/006176.html" target="_blank">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160104/006176.html</a></div><div><br></div><div>Parameter forwarding is the first in a series of three proposals describing general features that can work together to form a complete solution.</div><div><br></div><div><div>The proposal drafts can be found at the following links:</div><div><br></div><div>* <b>Parameter forwarding:</b> <a href="https://github.com/anandabits/swift-evolution/blob/parameter-forwarding/proposals/NNNN-parameter-forwarding.md" target="_blank">https://github.com/anandabits/swift-evolution/blob/parameter-forwarding/proposals/NNNN-parameter-forwarding.md</a></div><div>* <b>Partial initializers:</b> <a href="https://github.com/anandabits/swift-evolution/blob/partial-initializers/proposals/NNNN-partial-initializers.md" target="_blank">https://github.com/anandabits/swift-evolution/blob/partial-initializers/proposals/NNNN-partial-initializers.md</a></div><div>* <b>Property lists:</b> <a href="https://github.com/anandabits/swift-evolution/blob/property-lists/proposals/NNNN-property-lists.md" target="_blank">https://github.com/anandabits/swift-evolution/blob/property-lists/proposals/NNNN-property-lists.md</a></div></div><div><br></div><div>Matthew</div><div><h1 style="font-size:37px;line-height:42px;margin-top:42px;margin-bottom:21px;font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif">Parameter Forwarding</h1><ul style="margin-top:21px;margin-bottom:21px;padding-left:1.5em;color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;font-size:15px"><li style="font-size:17px">Proposal: <a href="https://github.com/apple/swift-evolution/blob/master/proposals/NNNN-parameter-forwarding.md" style="color:rgb(13,110,161);text-decoration:none" target="_blank">SE-NNNN</a></li><li style="font-size:17px">Author(s): <a href="https://github.com/anandabits" style="color:rgb(13,110,161);text-decoration:none" target="_blank">Matthew Johnson</a></li><li style="font-size:17px">Status: <strong style="line-height:1">Awaiting review</strong></li><li style="font-size:17px">Review manager: TBD</li></ul><h2 style="color:rgb(17,17,17);font-size:27px;line-height:42px;margin-top:42px;margin-bottom:21px;font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif">Introduction</h2><p style="color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;margin:1.3125em 0px;font-size:1.1429em;line-height:1.3125em">This feature introduces an automatic parameter forwarding mechanism.</p><p style="color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;margin:1.3125em 0px;font-size:1.1429em;line-height:1.3125em">Swift-evolution thread: <a href="https://lists.swift.org/pipermail/swift-evolution" style="color:rgb(13,110,161);text-decoration:none" target="_blank">Proposal Draft: parameter forwarding</a></p><h2 style="color:rgb(17,17,17);font-size:27px;line-height:42px;margin-top:42px;margin-bottom:21px;font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif">Motivation</h2><p style="color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;margin:1.3125em 0px;font-size:1.1429em;line-height:1.3125em">There are many cases where a function declares parameters simply for the purpose of forwarding the provided arguments to another function. This results in reduntant parameter specifications that make code less clear and less readable by obscuring the simple forwarding that is actually happening.</p><p style="color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;margin:1.3125em 0px;font-size:1.1429em;line-height:1.3125em">This feature will be especially useful in initializers such as:</p><ul style="margin-top:21px;margin-bottom:21px;padding-left:1.5em;color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;font-size:15px"><li style="font-size:17px">Convenience initializers that foward parameters directly to a designated initializer</li><li style="font-size:17px">Designated initializers that foward parameters directly to a super initializer</li><li style="font-size:17px">Designated initializers that foward parameters directly to a member initializer, perhaps in a composition-based design</li><li style="font-size:17px">If the partial initilaizer proposal is accepted, designated initializers that forward parameters to one or more partial initializers</li></ul><p style="color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;margin:1.3125em 0px;font-size:1.1429em;line-height:1.3125em">NOTE: I haven’t had time to think too much aboue use cases beyond initialization. Please share examples and I will add them to this proposal.</p><h2 style="color:rgb(17,17,17);font-size:27px;line-height:42px;margin-top:42px;margin-bottom:21px;font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif">Proposed solution</h2><p style="color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;margin:1.3125em 0px;font-size:1.1429em;line-height:1.3125em">The proposed solution is to introduce an automatic parameter forwarding mechansim. It allows users to provide direct arguments for some parameters while forwarding others.</p><p style="color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;margin:1.3125em 0px;font-size:1.1429em;line-height:1.3125em">The basic mechanism looks like this:</p><pre style="margin-top:21px;margin-bottom:21px;color:rgb(17,17,17);font-size:15px;background-color:rgb(248,248,248)"><code style="line-height:inherit;display:block;padding:0.5em;color:rgb(51,51,51);min-height:auto"><span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">foo</span><span>(i i: Int, s: String, f: Float = <span style="color:rgb(0,153,153)">42</span>, d: Double = <span style="color:rgb(0,153,153)">43</span>, b: Bool = <span>false</span>)</span></span> { }

<span style="color:rgb(153,153,136);font-style:italic">// user writes:</span>
<span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">bar</span><span>(...fooParams)</span></span> {
    foo(i: <span style="color:rgb(0,153,153)">32</span>, ...fooParams)
}

<span style="color:rgb(153,153,136);font-style:italic">// compiler synthesizes:</span>
<span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">bar</span><span>(s: String, f: Float = <span style="color:rgb(0,153,153)">42</span>, d: Double = <span style="color:rgb(0,153,153)">43</span>, b: Bool = <span>false</span>)</span></span> {
    foo(i: <span style="color:rgb(0,153,153)">32</span>, s: s, f: f, d: d, b: b)
}</code></pre><p style="color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;margin:1.3125em 0px;font-size:1.1429em;line-height:1.3125em">Some things to note about the syntax:</p><ol style="margin-top:21px;margin-bottom:21px;padding-left:1.5em;color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;font-size:15px"><li style="font-size:17px"><code style="line-height:1">...fooParams</code> is a placeholder introduced with <code style="line-height:1">...</code> and followed by an identifier.</li><li style="font-size:17px">In the signature it can be placed anywhere in the parameter list.</li><li style="font-size:17px">At the call site, it must appear at the end of the argument list.</li><li style="font-size:17px">The placeholder matches the parameters not directly provided including their external label and default value if those exist.</li><li style="font-size:17px">Parameters corresponding to the matched parameters are synthesized by the compiler where the placeholder exists in the parameter list, including the default argument if one exists.</li><li style="font-size:17px">The identifier portion of the placeholder may be omitted if only one set of forwarded parameters exist within the function.</li></ol><p style="color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;margin:1.3125em 0px;font-size:1.1429em;line-height:1.3125em">Additional details will be introduced with a corresponding example.</p><h3 style="color:rgb(17,17,17);margin:21px 0px;font-size:20px;line-height:21px;font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif">Omitting the placeholder identifier</h3><p style="color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;margin:1.3125em 0px;font-size:1.1429em;line-height:1.3125em">The above example can be written more concisely by omitting the placeholder identifier.</p><pre style="margin-top:21px;margin-bottom:21px;color:rgb(17,17,17);font-size:15px;background-color:rgb(248,248,248)"><code style="line-height:inherit;display:block;padding:0.5em;color:rgb(51,51,51);min-height:auto"><span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">foo</span><span>(i i: Int, s: String, f: Float = <span style="color:rgb(0,153,153)">42</span>, d: Double = <span style="color:rgb(0,153,153)">43</span>, b: Bool = <span>false</span>)</span></span> { }

<span style="color:rgb(153,153,136);font-style:italic">// user writes:</span>
<span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">bar</span><span>(...)</span></span> {
    foo(i: <span style="color:rgb(0,153,153)">32</span>, ...)
}

<span style="color:rgb(153,153,136);font-style:italic">// compiler synthesizes:</span>
<span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">bar</span><span>(s: String, f: Float = <span style="color:rgb(0,153,153)">42</span>, d: Double = <span style="color:rgb(0,153,153)">43</span>, b: Bool = <span>false</span>)</span></span> {
    foo(i: <span style="color:rgb(0,153,153)">32</span>, s: s, f: f, d: d, b: b)
}</code></pre><p style="color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;margin:1.3125em 0px;font-size:1.1429em;line-height:1.3125em">NOTE: If the community feels strongly that the identifier should be required I am willing to do so.</p><h3 style="color:rgb(17,17,17);margin:21px 0px;font-size:20px;line-height:21px;font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif">Multiple forwarded parameter sets</h3><p style="color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;margin:1.3125em 0px;font-size:1.1429em;line-height:1.3125em">It is possible for a single function to forward more than one set of parameters:</p><pre style="margin-top:21px;margin-bottom:21px;color:rgb(17,17,17);font-size:15px;background-color:rgb(248,248,248)"><code style="line-height:inherit;display:block;padding:0.5em;color:rgb(51,51,51);min-height:auto"><span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">foo</span><span>(i i: Int, s: String, f: Float = <span style="color:rgb(0,153,153)">42</span>)</span></span> { }
<span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">foo2</span><span>(d: Double = <span style="color:rgb(0,153,153)">43</span>, b: Bool = <span>false</span>)</span></span> { }

<span style="color:rgb(153,153,136);font-style:italic">// user writes:</span>
<span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">bar</span><span>(...fooParams, ...foo2Params)</span></span> {
    foo2(...foo2Params)
    foo(i: <span style="color:rgb(0,153,153)">32</span>, ...fooParams)
}

<span style="color:rgb(153,153,136);font-style:italic">// compiler synthesizes:</span>
<span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">bar</span><span>(s: String, f: Float = <span style="color:rgb(0,153,153)">42</span>, d: Double = <span style="color:rgb(0,153,153)">43</span>, b: Bool = <span>false</span>)</span></span> {
    foo(i: <span style="color:rgb(0,153,153)">32</span>, s: s, f: f, d: d, b: b)
}</code></pre><h3 style="color:rgb(17,17,17);margin:21px 0px;font-size:20px;line-height:21px;font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif">Direct arguments</h3><p style="color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;margin:1.3125em 0px;font-size:1.1429em;line-height:1.3125em">Any direct arguments provided in the forwarding call must follow the usual argument ordering rules, with the only exception being that it is allowed to omit some arguments that would normally be required. When the compiler performs forwarding it will insert forwarded arguments in the correct location.</p><pre style="margin-top:21px;margin-bottom:21px;color:rgb(17,17,17);font-size:15px;background-color:rgb(248,248,248)"><code style="line-height:inherit;display:block;padding:0.5em;color:rgb(51,51,51);min-height:auto"><span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">foo</span><span>(i i: Int, s: String, f: Float = <span style="color:rgb(0,153,153)">42</span>, d: Double = <span style="color:rgb(0,153,153)">43</span>, b: Bool = <span>false</span>)</span></span> { }

<span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">bar</span><span>(...fooParams)</span></span> {
    <span style="color:rgb(153,153,136);font-style:italic">// error: `i` must precede `s` in the argument list</span>
    foo(s: <span style="color:rgb(221,17,68)">&quot;hello&quot;</span>, i: <span style="color:rgb(0,153,153)">32</span>, ...fooParams)
}

<span style="color:rgb(153,153,136);font-style:italic">// user writes:</span>
<span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">bar</span><span>(...fooParams)</span></span> {
    foo(i: <span style="color:rgb(0,153,153)">32</span>, f: <span style="color:rgb(0,153,153)">0</span>, ...fooParams)
}

<span style="color:rgb(153,153,136);font-style:italic">// compiler synthesizes:</span>
<span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">bar</span><span>(s s: String, d: Double = <span style="color:rgb(0,153,153)">43</span>, b: Bool = <span>false</span>)</span></span> {
    foo(i: <span style="color:rgb(0,153,153)">32</span>, s: s, f: <span style="color:rgb(0,153,153)">0</span>, d: d, b: b)
}</code></pre><h3 style="color:rgb(17,17,17);margin:21px 0px;font-size:20px;line-height:21px;font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif">Multi-forwarding the same parameters</h3><p style="color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;margin:1.3125em 0px;font-size:1.1429em;line-height:1.3125em">It is allowed to use the same identifier in multiple forwarding calls as long as the signature of the matched parameters matches exactly, including any default values. </p><pre style="margin-top:21px;margin-bottom:21px;color:rgb(17,17,17);font-size:15px;background-color:rgb(248,248,248)"><code style="line-height:inherit;display:block;padding:0.5em;color:rgb(51,51,51);min-height:auto"><span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">foo</span><span>(i i: Int, s: String, d: Double = <span style="color:rgb(0,153,153)">43</span>)</span></span> { }
<span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">bar</span><span>(i i: Int, s: String, d: Double = <span style="color:rgb(0,153,153)">43</span>)</span></span> { }

<span style="color:rgb(153,153,136);font-style:italic">// user writes:</span>
<span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">baz</span><span>(...fooBarParams)</span></span> {
    foo(...fooBarParams)
    bar(...fooBarParams)
}

<span style="color:rgb(153,153,136);font-style:italic">// compiler synthesizes: </span>
<span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">baz</span><span>(i i: Int, s: String, d: Double = <span style="color:rgb(0,153,153)">43</span>)</span></span> {
    foo(i: i, s: s, d: d)
    bar(i: i, s: s, d: d)
}</code></pre><p style="color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;margin:1.3125em 0px;font-size:1.1429em;line-height:1.3125em">NOTE: This provision might be controversial. If the community doesn’t like it or the implementation is too complex I will remove it.</p><h3 style="color:rgb(17,17,17);margin:21px 0px;font-size:20px;line-height:21px;font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif">Unambiguous call</h3><p style="color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;margin:1.3125em 0px;font-size:1.1429em;line-height:1.3125em">When forwarding parameters to a function that is overloaded the caller must provide enough direct arguments to make the call unambiguous.</p><pre style="margin-top:21px;margin-bottom:21px;color:rgb(17,17,17);font-size:15px;background-color:rgb(248,248,248)"><code style="line-height:inherit;display:block;padding:0.5em;color:rgb(51,51,51);min-height:auto"><span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">foo</span><span>(i i: Int, s: String, d: Double = <span style="color:rgb(0,153,153)">43</span>, b: Bool = <span>false</span>)</span></span> { }
<span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">foo</span><span>(i i: Int, s: String, d: Double = <span style="color:rgb(0,153,153)">43</span>, f: Float = <span style="color:rgb(0,153,153)">42</span>)</span></span> { }

<span style="color:rgb(153,153,136);font-style:italic">// user writes:</span>
<span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">bar</span><span>(...fooParams)</span></span> {
    <span style="color:rgb(153,153,136);font-style:italic">// error: ambiguous use of foo</span>
    <span style="color:rgb(153,153,136);font-style:italic">// foo(i: 32, ...fooParams)</span>
    
    <span style="color:rgb(153,153,136);font-style:italic">// ok: `b` makes the call to foo unambiguous</span>
    foo(b: <span>true</span>, ...fooParams)
    <span style="color:rgb(153,153,136);font-style:italic">// ok: `f` makes the call to foo unambiguous</span>
    foo(f: <span style="color:rgb(0,153,153)">24</span>, ...fooParams)
}

<span style="color:rgb(153,153,136);font-style:italic">// compiler synthesizes: </span>
<span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">bar</span><span>(i i: Int, s: String, d: Double = <span style="color:rgb(0,153,153)">43</span>)</span></span> {
    foo(i: i, s: s, d: d, b: <span>true</span>)
    foo(i: i, s: s, d: d, f: <span style="color:rgb(0,153,153)">24</span>)
}</code></pre><h3 style="color:rgb(17,17,17);margin:21px 0px;font-size:20px;line-height:21px;font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif">Default values</h3><p style="color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;margin:1.3125em 0px;font-size:1.1429em;line-height:1.3125em">When forwarding to a function that accepts default values it is possible to explicitly request the default value. This allows for disambiguation and also allows the forwarding function to suppress a defaulted parameter from participating in forwarding without needing to supply a specific value. The <code style="line-height:1">default</code> keyword is used to do this.</p><p style="color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;margin:1.3125em 0px;font-size:1.1429em;line-height:1.3125em">We can modify the previous example to use the defualt values:</p><pre style="margin-top:21px;margin-bottom:21px;color:rgb(17,17,17);font-size:15px;background-color:rgb(248,248,248)"><code style="line-height:inherit;display:block;padding:0.5em;color:rgb(51,51,51);min-height:auto"><span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">foo</span><span>(i i: Int, s: String, d: Double = <span style="color:rgb(0,153,153)">43</span>, b: Bool = <span>false</span>)</span></span> { }
<span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">foo</span><span>(i i: Int, s: String, d: Double = <span style="color:rgb(0,153,153)">43</span>, f: Float = <span style="color:rgb(0,153,153)">42</span>)</span></span> { }

<span style="color:rgb(153,153,136);font-style:italic">// user writes:</span>
<span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">bar</span><span>(...fooParams)</span></span> {
    <span style="color:rgb(153,153,136);font-style:italic">// ok: `b` makes the call to foo unambiguous, still uses default value</span>
    foo(b: <span style="font-weight:bold">default</span>, ...fooParams)
    <span style="color:rgb(153,153,136);font-style:italic">// ok: `f` makes the call to foo unambiguous, still uses default value</span>
    foo(f: <span style="font-weight:bold">default</span>, ...fooParams)
}

<span style="color:rgb(153,153,136);font-style:italic">// compiler synthesizes:</span>
<span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">bar</span><span>(i i: Int, s: String, d: Double = <span style="color:rgb(0,153,153)">43</span>)</span></span> {
    foo(i: i, s: s, d: d, b: <span>false</span>)
    foo(i: i, s: s, d: d, f: <span style="color:rgb(0,153,153)">42</span>)
}</code></pre><p style="color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;margin:1.3125em 0px;font-size:1.1429em;line-height:1.3125em">It is also possible to explicitly request all defaults at once using <code style="line-height:1">default...</code>. In this example, <code style="line-height:1">foo</code>is not overloaded:</p><pre style="margin-top:21px;margin-bottom:21px;color:rgb(17,17,17);font-size:15px;background-color:rgb(248,248,248)"><code style="line-height:inherit;display:block;padding:0.5em;color:rgb(51,51,51);min-height:auto"><span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">foo</span><span>(i i: Int, s: String, d: Double = <span style="color:rgb(0,153,153)">43</span>, b: Bool = <span>false</span>)</span></span> { }

<span style="color:rgb(153,153,136);font-style:italic">// user writes:</span>
<span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">bar</span><span>(...fooParams)</span></span> {
    foo(<span style="font-weight:bold">default</span>..., ...fooParams)
}

<span style="color:rgb(153,153,136);font-style:italic">// compiler synthesizes:</span>
<span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">bar</span><span>(i i: Int, s: String)</span></span> {
    foo(i: i, s: s, d: <span style="color:rgb(0,153,153)">43</span>, b: <span>false</span>)
}</code></pre><p style="color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;margin:1.3125em 0px;font-size:1.1429em;line-height:1.3125em">NOTE: The actual implementation of default arguments looks somewhat different. These examples are intended to communicate the behavior, not the exact details of implementation.</p><h3 style="color:rgb(17,17,17);margin:21px 0px;font-size:20px;line-height:21px;font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif">Generic parameters</h3><p style="color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;margin:1.3125em 0px;font-size:1.1429em;line-height:1.3125em">If the types of any matched parameters reference any generic type parameters of the forwardee the generic type parameters must also be forwarded, along with any constraints on those generic parameters. </p><pre style="margin-top:21px;margin-bottom:21px;color:rgb(17,17,17);font-size:15px;background-color:rgb(248,248,248)"><code style="line-height:inherit;display:block;padding:0.5em;color:rgb(51,51,51);min-height:auto"><span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">foo</span><span>&lt;T&gt;</span><span>(i i: Int, s: String, t: T, d: Double = <span style="color:rgb(0,153,153)">43</span>, b: Bool = <span>false</span>)</span></span> { }

<span style="color:rgb(153,153,136);font-style:italic">// user writes:</span>
<span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">bar</span><span>(...fooParams)</span></span> {
    foo(...fooParams)
}

<span style="color:rgb(153,153,136);font-style:italic">// compiler synthesizes:</span>
<span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">bar</span><span>&lt;T&gt;</span><span>(i i: Int, s: String, t: T, d: Double = <span style="color:rgb(0,153,153)">43</span>, b: Bool = <span>false</span>)</span></span> {
    foo(i: i, s: s, t: t, d: d, b: b)
}</code></pre><p style="color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;margin:1.3125em 0px;font-size:1.1429em;line-height:1.3125em">If a generic parameter is referenced in a constraint that also references a generic parameter that will not be forwarded the constraint is resolved to a concrete type when possible. This may not be possible in all cases. When it is not possible a compiler error will be necessary.</p><pre style="margin-top:21px;margin-bottom:21px;color:rgb(17,17,17);font-size:15px;background-color:rgb(248,248,248)"><code style="line-height:inherit;display:block;padding:0.5em;color:rgb(51,51,51);min-height:auto"><span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">foo</span><span>&lt;S: SequenceType, T: SequenceType where S.Generator.Element == T.Generator.Element&gt;</span>
    <span>(s: S, t: T)</span></span> { }

<span style="color:rgb(153,153,136);font-style:italic">// user writes:</span>
<span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">bar</span><span>(...fooParams)</span></span> {
    foo(t: [<span style="color:rgb(0,153,153)">42</span>], ...fooParams)
}

<span style="color:rgb(153,153,136);font-style:italic">// compiler synthesizes:</span>
<span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">bar</span><span>&lt;S: SequenceType where S.Generator.Element == Int&gt;</span><span>(s: S)</span></span> {
    foo(s: s, t: [<span style="color:rgb(0,153,153)">42</span>])
}</code></pre><h3 style="color:rgb(17,17,17);margin:21px 0px;font-size:20px;line-height:21px;font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif">Syntheszied internal names</h3><p style="color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;margin:1.3125em 0px;font-size:1.1429em;line-height:1.3125em">The compiler must ensure that all synthesized parameters have internal names that do not conflict with the internal names of any manually declared parameters. This applies to both generic type parameter names as well as value arguments in the parameter list of the function.</p><pre style="margin-top:21px;margin-bottom:21px;color:rgb(17,17,17);font-size:15px;background-color:rgb(248,248,248)"><code style="line-height:inherit;display:block;padding:0.5em;color:rgb(51,51,51);min-height:auto"><span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">foo</span><span>&lt;T&gt;</span><span>(i i: Int, s: String, t: T, d: Double = <span style="color:rgb(0,153,153)">43</span>, b: Bool = <span>false</span>)</span></span> { }

<span style="color:rgb(153,153,136);font-style:italic">// user writes:</span>
<span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">bar</span><span>&lt;T&gt;</span><span>(t: T, ...fooParams)</span></span> {
    <span style="color:rgb(153,153,136);font-style:italic">// do something with t</span>
    foo(...fooParams)
}

<span style="color:rgb(153,153,136);font-style:italic">// compiler synthesizes:</span>
<span><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">bar</span><span>&lt;T, InternalCompilerIdentifier&gt;</span><span>(t: T, i i: Int, s: String, t internalCompilerIdentifier: InternalCompilerIdentifier, d: Double = <span style="color:rgb(0,153,153)">43</span>, b: Bool = <span>false</span>)</span></span> {
    foo(t: t, i: i, s: s, t: internalCompilerIdentifier, d: d, b: b)
}</code></pre><h2 style="color:rgb(17,17,17);font-size:27px;line-height:42px;margin-top:42px;margin-bottom:21px;font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif">Detailed design</h2><p style="color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;margin:1.3125em 0px;font-size:1.1429em;line-height:1.3125em">TODO but should fall out pretty clearly from the proposed solution</p><h2 style="color:rgb(17,17,17);font-size:27px;line-height:42px;margin-top:42px;margin-bottom:21px;font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif">Impact on existing code</h2><p style="color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;margin:1.3125em 0px;font-size:1.1429em;line-height:1.3125em">This is a strictly additive change. It has no impact on existing code.</p><h2 style="color:rgb(17,17,17);font-size:27px;line-height:42px;margin-top:42px;margin-bottom:21px;font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif">Alternatives considered</h2><p style="color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;margin:1.3125em 0px;font-size:1.1429em;line-height:1.3125em">I believe the forwarding mechanism itself is pretty straightforward and any alternatives would be lose functionality without good reason. </p><p style="color:rgb(17,17,17);font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;margin:1.3125em 0px;font-size:1.1429em;line-height:1.3125em">The placeholder syntax is of course fair game for bikeshedding. I consider anything reasonably clear and concise to be acceptable.</p></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=iRI3beHTe3UxYAHTlV3lA38zIPfHMhyuRzgTmGKV6k6PE08XyqhnW335s7EfoynLnb0RFI23FoJ5evCRSoe08HSSsG6aHPJkERLVoloVv9CZuKKNr0kJqgyyiaVzBhjiZfn-2BetdmRfPMDVc5mNV3QsbWXa78jKmnmumd6MFkpRAxhORq3UfUWCDywp3PNaYscppWoVMp-2FB-2BYo-2BN-2BRRA1ZTgK6DXoBkkXLae-2BtDLv8uY-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important">
</div>
_______________________________________________<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/mailman/listinfo/swift-evolution</a><br></div></blockquote></div><br></div></div></div></blockquote></div></div></div><br>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=3FGfocPbgxkNkmje7djckg9Iw-2BGYY3X6RxJ1tkUXKCoAdaEegu4AxpF0RlqR3GS6JsGSw-2BKX3W-2BMzMqASytaCCm0-2BdiC5w8wjKLxwuR0utnfEOiNZ8iDk0rSZu4OOhyfIcICvuXirZ6giTHDoc3oqQBujq8yP1xWdyde83B1ZAgj6wFTiJQgIImMNIbKbWU1xcx7s0UsN2JJrb1Em-2F4GyRB2Iis8kYPJov87e-2BcNr-2BI-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important">
</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><br></div></div></div></blockquote></div><br></div>
</div></blockquote></div><br></div></div></div></div></div></blockquote></div><br></div>
</div></blockquote></div></div></div><br></div></blockquote></div><br></div>