<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="">On Jan 10, 2016, at 7:44 PM, Matthew Johnson via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><div><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><h2 id="proposedsolution" style="color: rgb(17, 17, 17); font-size: 27px; line-height: 42px; margin-top: 42px; margin-bottom: 21px; font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif;" class="">Proposed solution</h2><p style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;" class="">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: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;" class="">The basic mechanism looks like this:</p><pre style="margin-top: 21px; margin-bottom: 21px; tab-size: 4; color: rgb(17, 17, 17); font-size: 15px; background-color: rgb(248, 248, 248);" class=""><code class="swift hljs" style="line-height: inherit; display: block; padding: 0.5em; color: rgb(51, 51, 51); height: auto;"><span class="hljs-func"><span class="hljs-keyword" style="font-weight: bold;">func</span> <span class="hljs-title" style="color: rgb(153, 0, 0); font-weight: bold;">foo</span><span class="hljs-params">(i i: Int, s: String, f: Float = <span class="hljs-number" style="color: rgb(0, 153, 153);">42</span>, d: Double = <span class="hljs-number" style="color: rgb(0, 153, 153);">43</span>, b: Bool = <span class="hljs-literal">false</span>)</span></span> { }
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// user writes:</span>
<span class="hljs-func"><span class="hljs-keyword" style="font-weight: bold;">func</span> <span class="hljs-title" style="color: rgb(153, 0, 0); font-weight: bold;">bar</span><span class="hljs-params">(...fooParams)</span></span> {
foo(i: <span class="hljs-number" style="color: rgb(0, 153, 153);">32</span>, ...fooParams)
}
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// compiler synthesizes:</span>
<span class="hljs-func"><span class="hljs-keyword" style="font-weight: bold;">func</span> <span class="hljs-title" style="color: rgb(153, 0, 0); font-weight: bold;">bar</span><span class="hljs-params">(s: String, f: Float = <span class="hljs-number" style="color: rgb(0, 153, 153);">42</span>, d: Double = <span class="hljs-number" style="color: rgb(0, 153, 153);">43</span>, b: Bool = <span class="hljs-literal">false</span>)</span></span> {
foo(i: <span class="hljs-number" style="color: rgb(0, 153, 153);">32</span>, s: s, f: f, d: d, b: b)
}</code></pre></div></div></div></blockquote>This approach is extremely problematic and unlikely to be accepted.</div><div><br class=""></div><div>Swift is carefully designed so that the compiler can type check the interface to a function without type checking its body. This is important for compiler scalability to large projects, IDE tooling, and also because otherwise you can run into circular dependencies to compile the code.</div><div><br class=""></div><div>Another major problem with this approach is that it only works if “foo” is unambiguous.</div><div><br class=""></div><div>-Chris</div><br class=""></body></html>