<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="">I would not want to have to deal with inout, as "bad things could happen"™ And I'm imagining arbitrary params, not just rightmost,</div><div class="">although I would defer to implementation realities (such as not using _) as needed.</div><div class=""><br class=""></div><div class="">-- E</div><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 2, 2016, at 11:14 AM, Austin Zheng &lt;<a href="mailto:austinzheng@gmail.com" class="">austinzheng@gmail.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 style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I like this ad-hoc currying proposal.<div class=""><br class=""></div><div class="">Questions:</div><div class="">- How does this handle inout params? Are they just not allowed, to keep things simple? Or are they allowed as long as they aren't the parameter being curried?</div><div class="">- Would you be able to curry arbitrary params in the function decl, or only the <i class="">n</i>&nbsp;rightmost params?</div><div class=""><br class=""></div><div class="">Best,</div><div class="">Austin</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class=""><blockquote type="cite" class=""><div class="">On Feb 2, 2016, at 10:10 AM, Michael Ilseman via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Feb 2, 2016, at 9:33 AM, Erica Sadun via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">First draft. Let's go Scala!<div class=""><br class=""></div><div class="">-- E</div><div class=""><br class=""></div><div class=""><h1 style="box-sizing: border-box; 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="">Automating Partial Application via Wildcards</h1><ul style="box-sizing: border-box; padding: 0px 0px 0px 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 style="box-sizing: border-box;" class="">Proposal: TBD</li><li style="box-sizing: border-box;" class="">Author(s):&nbsp;<a href="http://github.com/erica" style="box-sizing: border-box; background-color: transparent; color: rgb(64, 120, 192); text-decoration: none;" class="">Erica Sadun</a>,&nbsp;<a href="http://github.com/DeFrenZ" style="box-sizing: border-box; background-color: transparent; color: rgb(64, 120, 192); text-decoration: none;" class="">Davide De Franceschi</a></li><li style="box-sizing: border-box;" class="">Status: TBD</li><li style="box-sizing: border-box;" class="">Review manager: TBD</li></ul><h2 style="box-sizing: border-box; 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 id="user-content-introduction" class="anchor" href="https://gist.github.com/erica/6327981d42eb9be6b4d2#introduction" aria-hidden="true" style="box-sizing: border-box; background-color: transparent; color: rgb(64, 120, 192); text-decoration: none; display: inline-block; padding-right: 2px; margin-left: -18px; line-height: 1;"><svg aria-hidden="true" class="octicon octicon-link" height="16" role="img" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1h-1c-1.5 0-3-1.69-3-3.5s1.55-3.5 3-3.5h4c1.45 0 3 1.69 3 3.5 0 1.41-0.91 2.72-2 3.25v-1.16c0.58-0.45 1-1.27 1-2.09 0-1.28-1.02-2.5-2-2.5H4c-0.98 0-2 1.22-2 2.5s1 2.5 2 2.5z m9-3h-1v1h1c1 0 2 1.22 2 2.5s-1.02 2.5-2 2.5H9c-0.98 0-2-1.22-2-2.5 0-0.83 0.42-1.64 1-2.09v-1.16c-1.09 0.53-2 1.84-2 3.25 0 1.81 1.55 3.5 3 3.5h4c1.45 0 3-1.69 3-3.5s-1.5-3.5-3-3.5z"></path></svg></a>Introduction</h2><p style="box-sizing: border-box; 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=""><a href="https://github.com/apple/swift-evolution/blob/master/proposals/0002-remove-currying.md" style="box-sizing: border-box; background-color: transparent; color: rgb(64, 120, 192); text-decoration: none;" class="">SE-0002</a>&nbsp;has been accepted for Swift 3.0. That proposal removes currying func declaration syntax from Swift. It reasons that currying introduces unnecessary language and implementation complexity and is easily replaced with chained function return types.&nbsp;</p><p style="box-sizing: border-box; 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="">Because of SE-0002, this curried example:</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; 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);"><pre style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; padding: 16px; 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-wrap: normal; word-break: normal;" class=""><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">public</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">projectFunctionToCoordinateSystem</span>(function <span class="pl-smi" style="box-sizing: border-box;">f</span>: FunctionType)(p0: CGPoint, p1: CGPoint)(x: CGFloat) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-&gt;</span> CGPoint</pre></div><p style="box-sizing: border-box; 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="">becomes</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; 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);"><pre style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; padding: 16px; 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-wrap: normal; word-break: normal;" class=""><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">public</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">projectFunctionToCoordinateSystem</span>(function <span class="pl-smi" style="box-sizing: border-box;">f</span>: FunctionType) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-&gt;</span> (p0: CGPoint, p1: CGPoint) -&gt; (x: CGFloat) -&gt; CGPoint </pre></div><p style="box-sizing: border-box; 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 3.</p><p style="box-sizing: border-box; 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="">It's mechanically simple to re-introduce partial application but the current solution adds unnecessary nesting and complicated closure declarations, as you see in the following Swift 3 version of this projection function.</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; 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);"><pre style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; padding: 16px; 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-wrap: normal; word-break: normal;" class=""><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">public</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">projectFunctionToCoordinateSystem</span>(function <span class="pl-smi" style="box-sizing: border-box;">f</span>: FunctionType) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-&gt;</span> (p0: CGPoint, p1: CGPoint) -&gt; (x: CGFloat) -&gt; CGPoint {
  <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">return</span> { p0, p1 <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">in</span>
    <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">return</span> { x <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">in</span>
      <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> (dx, dy) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> (p1<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>x <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-</span> p0<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>x, p1<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>y <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-</span> p0<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>y)
      <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> (magnitude, theta) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> (hypot(dy, dx), atan2(dy, dx)) <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// Thanks loooop</span>
      <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">var</span> outPoint <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> CGPoint(x: x <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">*</span> magnitude, y: f(x) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">*</span> magnitude)
      outPoint <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> CGPointApplyAffineTransform(outPoint, CGAffineTransformMakeRotation(theta))
      outPoint <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> CGPointApplyAffineTransform(outPoint, CGAffineTransformMakeTranslation(p0<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>x, p0<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>y))
      <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">return</span> CGPoint(x: outPoint<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>x, y: outPoint<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>y)
    }
  }
}</pre></div><p style="box-sizing: border-box; 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="">SE-0002 mentions the possibility of introducing Scala-style free-form partial implementation as a future step. This proposal requests that a Scala-style wildcard feature be adopted into Swift by introducing a form of automatic partial application.</p><h2 style="box-sizing: border-box; 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 id="user-content-detail-design" class="anchor" href="https://gist.github.com/erica/6327981d42eb9be6b4d2#detail-design" aria-hidden="true" style="box-sizing: border-box; background-color: transparent; color: rgb(64, 120, 192); text-decoration: none; display: inline-block; padding-right: 2px; margin-left: -18px; line-height: 1;"><svg aria-hidden="true" class="octicon octicon-link" height="16" role="img" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1h-1c-1.5 0-3-1.69-3-3.5s1.55-3.5 3-3.5h4c1.45 0 3 1.69 3 3.5 0 1.41-0.91 2.72-2 3.25v-1.16c0.58-0.45 1-1.27 1-2.09 0-1.28-1.02-2.5-2-2.5H4c-0.98 0-2 1.22-2 2.5s1 2.5 2 2.5z m9-3h-1v1h1c1 0 2 1.22 2 2.5s-1.02 2.5-2 2.5H9c-0.98 0-2-1.22-2-2.5 0-0.83 0.42-1.64 1-2.09v-1.16c-1.09 0.53-2 1.84-2 3.25 0 1.81 1.55 3.5 3 3.5h4c1.45 0 3-1.69 3-3.5s-1.5-3.5-3-3.5z"></path></svg></a>Detail Design</h2><p style="box-sizing: border-box; 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="">The proposed design replaces a Swift 3 curried signature like this:&nbsp;</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; 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);"><pre style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; padding: 16px; 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-wrap: normal; word-break: normal;" class=""><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">public</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">projectFunctionToCoordinateSystem</span>(function <span class="pl-smi" style="box-sizing: border-box;">f</span>: FunctionType) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-&gt;</span> (p0: CGPoint, p1: CGPoint) -&gt; (x: CGFloat) -&gt; CGPoint</pre></div><p style="box-sizing: border-box; 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="">with a non-curried, fully qualified call like this:</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; 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);"><pre style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; padding: 16px; 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-wrap: normal; word-break: normal;" class=""><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">public</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">projectFunctionToCoordinateSystem</span>(function <span class="pl-smi" style="box-sizing: border-box;">f</span>: FunctionType, p0: CGPoint, p1: CGPoint, x: CGFloat) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-&gt;</span> CGPoint</pre></div><p style="box-sizing: border-box; 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="">When called with wildcard tokens, the function is partially applied using the supplied arguments. For example:</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; 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);"><pre style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; padding: 16px; 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-wrap: normal; word-break: normal;" class=""><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> partial1 <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> projectFunctionToCoordinateSystem(function: mySinFunction, p0: p0, p1: p1, x: _)
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// partial1(x: xValue)</span>

<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> partial2 <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> projectFunctionToCoordinateSystem(function: mySinFunction, p0: <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>zero, p1: _, x: _)
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// partial2(p1: p1Value, x: xValue) </span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// or</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// let partial3 = partial2(p1: p1Value, x: _); partial3(x: 0.25)</span></pre></div><p style="box-sizing: border-box; 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 returns a curried form. Labels are retained and used, and the compiler should throw an error for any ambiguity that arises as a side effect.</p><div class=""><br class=""></div></div></div></div></blockquote><div class=""><br class=""></div><div class="">To someone more familiar with the implementation of type checking than myself: how much would this complicate overload resolution, as there are no constraints or contextual typing information present in “_”? Would this, in practice, be any worse than something like:</div><div class=""><br class=""></div><div class=""><div class=""><div class="">func foo(a : Int, b b: Int?) -&gt; Int {</div><div class="">&nbsp; &nbsp; if let b = b {</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; return a + b</div><div class="">&nbsp; &nbsp; }</div><div class="">&nbsp; &nbsp; return a</div><div class="">}</div><div class="">func foo(a : Int, b b: Float?) -&gt; Float {</div><div class="">&nbsp; &nbsp; if let b = b {</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; return Float(a) + b</div><div class="">&nbsp; &nbsp; }</div><div class="">&nbsp; &nbsp; return Float(a)</div><div class="">}</div><div class=""><br class=""></div><div class="">let a = foo(1, b: 2) // Int: 3</div><div class="">let b = foo(1, b: 2.0) // Float: 3</div><div class="">let c = foo(1, b: nil) // Error: ambiguous use of 'foo(_:b:)'</div><div class=""><br class=""></div></div></div><br class=""><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=""><p style="box-sizing: border-box; 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="">The function implementation is fully configured as if all parameters are specified, losing all its nested&nbsp;<code style="box-sizing: border-box; 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="">params in/params in/params in...</code>&nbsp;overhead:</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; 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);"><pre style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; padding: 16px; 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-wrap: normal; word-break: normal;" class=""><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">public</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">projectFunctionToCoordinateSystem</span>(function <span class="pl-smi" style="box-sizing: border-box;">f</span>: FunctionType, p0: CGPoint, p1: CGPoint, x: CGFloat) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-&gt;</span> CGPoint {
  <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> (dx, dy) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> (p1<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>x <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-</span> p0<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>x, p1<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>y <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-</span> p0<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>y)
  <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> (magnitude, theta) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> (hypot(dy, dx), atan2(dy, dx)) <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// Thanks loooop</span>
  <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">var</span> outPoint <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> CGPoint(x: x <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">*</span> magnitude, y: f(x) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">*</span> magnitude)
  outPoint <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> CGPointApplyAffineTransform(outPoint, CGAffineTransformMakeRotation(theta))
  outPoint <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> CGPointApplyAffineTransform(outPoint, CGAffineTransformMakeTranslation(p0<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>x, p0<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>y))
  <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">return</span> CGPoint(x: outPoint<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>x, y: outPoint<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>y)
}</pre></div><p style="box-sizing: border-box; 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="">The result is simple, readable, and written independently of how the currying is to be applied. as under this design, any parameter can be curried.</p><h2 style="box-sizing: border-box; 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 id="user-content-alternatives-considered" class="anchor" href="https://gist.github.com/erica/6327981d42eb9be6b4d2#alternatives-considered" aria-hidden="true" style="box-sizing: border-box; background-color: transparent; color: rgb(64, 120, 192); text-decoration: none; display: inline-block; padding-right: 2px; margin-left: -18px; line-height: 1;"><svg aria-hidden="true" class="octicon octicon-link" height="16" role="img" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1h-1c-1.5 0-3-1.69-3-3.5s1.55-3.5 3-3.5h4c1.45 0 3 1.69 3 3.5 0 1.41-0.91 2.72-2 3.25v-1.16c0.58-0.45 1-1.27 1-2.09 0-1.28-1.02-2.5-2-2.5H4c-0.98 0-2 1.22-2 2.5s1 2.5 2 2.5z m9-3h-1v1h1c1 0 2 1.22 2 2.5s-1.02 2.5-2 2.5H9c-0.98 0-2-1.22-2-2.5 0-0.83 0.42-1.64 1-2.09v-1.16c-1.09 0.53-2 1.84-2 3.25 0 1.81 1.55 3.5 3 3.5h4c1.45 0 3-1.69 3-3.5s-1.5-3.5-3-3.5z"></path></svg></a>Alternatives Considered</h2><p style="box-sizing: border-box; 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="">Although our natural inclination is to use standard currying and partial application, we also considered defaulting arguments. In this scenario, wildcards return a version of the function with defaulted arguments for all non-wildcard values. In such a design,&nbsp;</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; 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);"><pre style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; padding: 16px; 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-wrap: normal; word-break: normal;" class=""><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> defaultedVersion <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> projectFunctionToCoordinateSystem(function: mySinFunction, p0: <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>zero, p1: _, x: _)</pre></div><p style="box-sizing: border-box; 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="">could be called with a&nbsp;<code style="box-sizing: border-box; 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="">p0</code>&nbsp;parameter even though that same parameter was already specified in the assignment as in the following example. So this:</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; 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);"><pre style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; padding: 16px; 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-wrap: normal; word-break: normal;" class="">defaultedVersion(p0: myNewOrigin, p1: myPoint, x: <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">0</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span><span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">5</span>)</pre></div><p style="box-sizing: border-box; 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="">expands to:</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; 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);"><pre style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; padding: 16px; 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-wrap: normal; word-break: normal;" class="">defaultedVersionOfProjectFunctionToCoordinateSystem(function: mySinFunction, p0: myNewOrigin, p1: myPoint, x: <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">0</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span><span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">5</span>)</pre></div><p style="box-sizing: border-box; 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="">where the new version of&nbsp;<code style="box-sizing: border-box; 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="">p0</code>&nbsp;overrides the defaulted version created in the initial wildcard assignment.</p><div style="box-sizing: border-box; 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="">The implementation details for this alternative approach would differ but it might be easier to implement. As you'd expect, any function called with fully qualified arguments would be executed rather than returning a defaulted version (or a partially applied version for the non-alternative implementation).</div></div></div>_______________________________________________<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" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div>_______________________________________________<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" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></body></html>