<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">This is another reaction to <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0066-standardize-function-type-syntax.md" class="">SE-0066</a> to which I'm mildly against.<div class=""><br class=""></div><div class="">I'd like to propose the following language changes to simplify function types and clarify what a function's name is. What gets removed is already ambiguous. And what is added makes higher-level programming with functions considerably simpler than currently. Furthermore, the proposed change considerably limits what constitutes the overload set of a function, which probably also speeds up the compilation process.</div><div class=""><br class=""></div><div class="">Let's consider the following declarations:</div><div class=""><br class=""></div><div class=""><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> <b class="">func</b> foo() </span><font color="#919191" style="font-size: 11px;" class="">// #1 </font></font><font color="#919191" face="Menlo" style="font-size: 11px;" class="">Function named '<b class="">foo(_)</b>' with type '<b class="">() -> ()</b>'.</font></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> <b class="">func</b> foo(x: Int) -> Int </span><font color="#919191" style="font-size: 11px;" class="">// #2 </font></font><font color="#919191" face="Menlo" style="font-size: 11px;" class="">Function named '<b class="">foo(x:)</b>' with type '<b class="">Int -> Int</b>' (not an overload).</font></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> <b class="">func</b> foo(_ x: Int) -> Int </span><font color="#919191" style="font-size: 11px;" class="">// #3 </font></font><font color="#919191" face="Menlo" style="font-size: 11px;" class="">Function named '<b class="">foo(_:)</b>' with type '<b class="">Int -> Int</b>'</font></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> <b class="">func</b> foo(_ x: (Int, Int)) -> Int </span><font color="#919191" style="font-size: 11px;" class="">// #4 Function named '<b class="">foo(_:)</b>' with type '<b class="">(Int, Int) -> Int</b>' (overload of #3).</font></font></div><div class=""><span style="font-family: Menlo; font-size: 11px;" class=""> <b class="">func</b> foo(x: Int, y: Int) -> Int </span><font color="#919191" style="font-family: Menlo; font-size: 11px;" class="">// #5 Function named '<b class="">foo(x:y:)</b>' with type '<b class="">(Int, Int) -> Int</b>'.</font></div><div class=""><span style="font-family: Menlo; font-size: 11px;" class=""> <b class="">func</b> foo(x: Int, y: Int) -> Bool </span><font color="#919191" style="font-family: Menlo; font-size: 11px;" class="">// #6 Function named '<b class="">foo(x:y:)</b>' with type '<b class="">(Int, Int) -> Bool</b>' (overload of #5).</font></div><div class=""><span style="font-family: Menlo; font-size: 11px;" class=""> </span><font color="#ff2600" style="font-family: Menlo; font-size: 11px;" class=""><b class="">let</b> foo: Int</font><font color="#919191" face="Menlo" style="font-size: 11px;" class=""> // <b class="">error:</b> invalid redeclaration of 'foo' (previously declared as a function)</font></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> <b class="">let</b> baz: (Int, Int) -> Int </span><font color="#919191" style="font-size: 11px;" class="">// #7 Variable named '<b class="">baz</b>' with type '<b class="">(Int, Int) -> Int</b>'.</font></font></div></div><div class=""><div class=""><span style="font-family: Menlo; font-size: 11px;" class=""> </span><b style="font-family: Menlo; font-size: 11px;" class="">class</b><span style="font-family: Menlo; font-size: 11px;" class=""> Bar {</span></div><div class=""><span style="font-family: Menlo; font-size: 11px;" class=""> </span><b style="font-family: Menlo; font-size: 11px;" class="">func</b><span style="font-family: Menlo; font-size: 11px;" class=""> baz() </span><span style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">// #8 Method named '</span><b style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">Bar.baz(_)</b><span style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">' with type '<b class="">Bar -> () -> ()</b>'.</span></div><div class=""><span style="font-family: Menlo; font-size: 11px;" class=""> </span><b style="font-family: Menlo; font-size: 11px;" class="">func</b><span style="font-family: Menlo; font-size: 11px;" class=""> baz(x y: Int) </span><span style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">// #9 Method named '</span><b style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">Bar.baz(x:)</b><span style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">' with type '<b class="">Bar -> Int -> ()</b>'.</span></div><div class=""><span style="font-size: 11px; font-family: Menlo;" class=""> </span><span style="font-size: 11px; font-family: Menlo;" class=""> </span><b style="font-size: 11px; font-family: Menlo;" class="">static func</b><span style="font-size: 11px; font-family: Menlo;" class=""> </span><span style="font-size: 11px; font-family: Menlo;" class="">baz(x: Int = 0) </span><span style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">// #10 Static method named '</span><b style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">Bar.Self.baz(x:)</b><span style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">' with type '<b class="">Int -> ()</b>'.</span></div><div class=""><span style="font-family: Menlo; font-size: 11px;" class=""> }</span></div></div><div class=""><span style="font-family: Menlo; font-size: 11px;" class=""> <font color="#ff2600" class=""><b class="">let</b> f1</font></span><span style="font-family: Menlo; font-size: 11px;" class=""><font color="#ff2600" class=""> = foo</font><font color="#919191" class=""> // <b class="">error:</b> not a function reference, did you mean 'foo(_)'?</font></span></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> <font color="#ff2600" class=""><b class="">let</b> f2</font><font color="#ff2600" class=""> = foo <b class="">as</b> () -> ()</font> </span></font><font color="#919191" style="font-family: Menlo; font-size: 11px;" class="">// <b class="">error:</b> not a function reference, did you mean 'foo(_)'?</font></div><div class=""><span style="font-family: Menlo; font-size: 11px;" class=""> <b class="">let</b> f3</span><span style="font-family: Menlo; font-size: 11px;" class=""> = foo(_) </span><span style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">// #11 Function reference to #1. Has type '<b class="">() -> ()</b>'.</span></div><div class=""><span style="font-family: Menlo; font-size: 11px;" class=""> <b class="">let</b> f4 = foo(x:) </span><span style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">// #12 Function reference to #2.</span><span style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class=""> </span><span style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">Has type '<b class="">Int -> Int</b>'.</span></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> <font color="#ff2600" class=""><b class="">let</b> f5</font><font color="#ff2600" class=""> = foo(_:)</font> </span></font><span style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">// <b class="">error:</b> ambiguous function reference. Could be 'Int -> Int' or '(Int, Int) -> Int'</span></div><div class=""><span style="font-family: Menlo; font-size: 11px;" class=""> <b class="">let</b> f6</span><span style="font-family: Menlo; font-size: 11px;" class=""> = foo(_:) <b class="">as</b> Int -> Int </span><span style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">// #13 Function reference to #3. Has type '<b class="">Int -> Int</b>'.</span></div><div class=""><span style="font-family: Menlo; font-size: 11px;" class=""> <b class="">let</b> f7</span><span style="font-family: Menlo; font-size: 11px;" class=""> = foo(_:) <b class="">as</b> (Int, Int) -> Int </span><span style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">// #14 Function reference to #4. Has type '<b class="">(Int, Int) -> Int</b>'.</span></div><div class=""><span style="font-family: Menlo; font-size: 11px;" class=""> <b class="">let</b> x1: Int</span><span style="font-family: Menlo; font-size: 11px;" class=""> = foo(x:y:)(1, 2) </span><span style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">// #15 Function application of #5. Picks the right overload by explicit return type.</span></div><div class=""><span style="font-family: Menlo; font-size: 11px;" class=""> <b class="">let</b> x2: Bool</span><span style="font-family: Menlo; font-size: 11px;" class=""> = foo(x:y:)((1, 2)) </span><span style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">// #16 Function application of #6. Allowing a tuple here causes no ambiguity.</span></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> <b class="">let</b> f9 = baz </span></font><span style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">// #17 Function reference synonymous to #7. Has type </span><span style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">'</span><b style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">(Int, Int) -> Int</b><span style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">'.</span></div><div class=""><span style="font-family: Menlo; font-size: 11px;" class=""> <b class="">let</b> bar = Bar()</span></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> </span></font><font color="#ff2600" face="Menlo" style="font-size: 11px;" class=""><b class="">let</b> f10 = bar.baz</font><font face="Menlo" class=""><span style="font-size: 11px;" class=""> </span></font><span style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">// <b class="">error:</b> not a function reference, did you mean 'bar.baz(_)' or 'bar.baz(x:)'?</span></div><div class=""><div class=""><span style="font-family: Menlo; font-size: 11px;" class=""> <b class="">let</b> f11 = bar.baz(_) </span><span style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">// #18 Function synonymous to the closure '{ bar.baz() }' with type '<b class="">() -> ()</b>'.</span></div></div><div class=""><div class=""><span style="font-family: Menlo; font-size: 11px;" class=""> <b class="">let</b> f12 = bar.baz(x:) </span><span style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">// #19 Function synonymous to the closure '{ bar.baz(x: $0) }' with type '<b class="">Int -> ()</b>'.</span></div></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> let f13 = Bar.Self.baz(x:) </span></font><font color="#919191" face="Menlo" style="font-size: 11px;" class="">// #20 Function synonymous to the closure '{ Bar.baz(x: $0) }' with type '</font><b style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">Int -> ()</b><span style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">'.</span></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> let f14 = Bar.Self.baz(_) </span></font><font color="#919191" face="Menlo" style="font-size: 11px;" class="">// #21 Function synonymous to the closure '{ Bar.baz() }' with type '<b class="">() -> ()</b>'.</font></div><div class=""><br class=""></div><div class="">The following list of proposed changes sum up what's new above.</div><div class=""><br class=""></div><div class="">C1: Extend <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0021-generalized-naming.md" class="">SE-0021</a> by <b class="">adding</b> the underscore-in-parentheses syntax `<font face="Menlo" class=""><span style="font-size: 11px;" class="">foo(_)</span></font>` to refer to the zero-argument function #1.</div><div class=""><br class=""></div><div class="">C2: Extend <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0021-generalized-naming.md" class="">SE-0021</a> by <b class="">removing</b> the ambiguity between instance and type members. From now on, `Bar.baz(_)` </div><div class=""><br class=""></div><div class="">C3: Extend <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0021-generalized-naming.md" class="">SE-0021</a> by <b class="">banning</b> the use of <i class="">base name only</i> to refer to a function, i.e. neither `<font face="Menlo" class=""><span style="font-size: 11px;" class="">foo</span></font>` nor `<font face="Menlo" class=""><span style="font-size: 11px;" class="">Bar.baz</span></font>` can be used to refer to refer to any of #1–#6 or #8–#10.</div><div class=""><br class=""></div><div class="">C4: Extend <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0021-generalized-naming.md" class="">SE-0021</a> to <b class="">allow</b> the selective omission of defaulted arguments, e.g. `<font face="Menlo" class=""><span style="font-size: 11px;" class=""><b class="">let</b> f = print(_:separator:)</span></font>` creates the function variable `<font face="Menlo" class=""><span style="font-size: 11px;" class="">f: (Any, String) -> ()</span></font>` equivalent to `<font face="Menlo" class=""><span style="font-size: 11px;" class="">{ print($0, separator: $1) }</span></font>`.</div><div class=""><br class=""></div><div class="">C5: <b class="">Clarify</b> the language specification by stating that <b class="">functions with different labels</b> (e.g. `<font face="Menlo" class=""><span style="font-size: 11px;" class="">foo(_:)</span></font>` vs. `<font face="Menlo" class=""><span style="font-size: 11px;" class="">foo(x:)</span></font>`) <b class="">are not overloads </b>of each other. Instead, two functions are considered overloads of each other if only if they have matching base names (e.g. `<font face="Menlo" class=""><span style="font-size: 11px;" class="">foo</span></font>`) and matching argument labels (e.g. `<font face="Menlo" class=""><span style="font-size: 11px;" class="">(x:y:)</span></font>`) but differing argument or return types (e.g. #3 and #4, or #5 and #6).</div><div class=""><br class=""></div><div class="">C6: <b class="">Clarify</b> that by using the base name `<font face="Menlo" class=""><span style="font-size: 11px;" class="">foo</span></font>` for a function, the same scope cannot define a variable with the name `<font face="Menlo" class=""><span style="font-size: 11px;" class="">foo</span></font>`. And, vice versa, in a scope that defines a variable named `<font face="Menlo" class=""><span style="font-size: 11px;" class="">foo</span></font>`, there can be no function `<font face="Menlo" class=""><span style="font-size: 11px;" class="">foo(...)</span></font>` defined at the same scope level.</div><div class=""><br class=""></div><div class="">The implications are:</div><div class=""><br class=""></div><div class="">I1: The use of a function's base name to refer to a function will cease to work. It has, however, been buggy up to this date. Consider the following:</div><div class=""><br class=""></div><div class=""><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> <b class="">let</b> f = [Int].prefix </span><font color="#919191" style="font-size: 11px;" class="">// '[Int] -> Int -> ArraySlice<Int>'</font></font></div><div class=""><font face="Menlo" class=""><font color="#919191" style="font-size: 11px;" class=""><br class=""></font></font></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> <b class="">let</b> g1 = [Int].dropFirst </span><font color="#919191" style="font-size: 11px;" class="">// Inexplicably chooses the '[Int] -> Int -> ArraySlice<Int>' overload!</font></font></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> <b class="">let</b> g2 = [Int].dropFirst <b class="">as</b> [Int] -> () -> ArraySlice<Int> </span></font><font color="#919191" face="Menlo" style="font-size: 11px;" class="">// Disambiguate</font><span style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class=""> </span><span style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">by type</span><span style="font-size: 11px; color: rgb(145, 145, 145); font-family: Menlo;" class="">.</span></div><div class=""><font color="#919191" face="Menlo" style="font-size: 11px;" class=""><br class=""></font></div><div class=""><span style="font-family: Menlo; font-size: 11px;" class=""> <b class="">let</b> h1 = [Int].sorted </span><font color="#919191" style="font-family: Menlo; font-size: 11px;" class="">// Chooses the '[Int] -> () -> [Int]' overload, unlike 'dropFirst' above.</font></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> </span></font><b style="font-family: Menlo; font-size: 11px;" class="">let</b><font face="Menlo" class=""><span style="font-size: 11px;" class=""> h2 = [Int].sorted <b class="">as</b> [Int] -> ((Int, Int) -> Bool) -> [Int] </span></font><font color="#919191" face="Menlo" style="font-size: 11px;" class="">// Disambiguate by type.</font></div></div><div class=""><br class=""></div><div class="">With the proposed changes, the above becomes:</div><div class=""><br class=""></div><div class=""><div class=""><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> <b class="">let</b> f = [Int].prefix(_:) </span><font color="#919191" style="font-size: 11px;" class="">// '[Int] -> Int -> ArraySlice<Int>'</font></font></div><div class=""><font face="Menlo" class=""><font color="#919191" style="font-size: 11px;" class=""><br class=""></font></font></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> <b class="">let</b> g1 = [Int].dropFirst(_:) </span><font color="#919191" style="font-size: 11px;" class="">// '[Int] -> Int -> ArraySlice<Int>'</font></font></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> <b class="">let</b> g2 = [Int].dropFirst(_) </span></font><span style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">// '[Int] -> () -> ArraySlice<Int>'</span></div><div class=""><font color="#919191" face="Menlo" style="font-size: 11px;" class=""><br class=""></font></div><div class=""><span style="font-family: Menlo; font-size: 11px;" class=""> <b class="">let</b> h1 = [Int].sorted(_) </span><font color="#919191" style="font-family: Menlo; font-size: 11px;" class="">// '[Int] -> () -> [Int]'</font></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> </span></font><b style="font-family: Menlo; font-size: 11px;" class="">let</b><font face="Menlo" class=""><span style="font-size: 11px;" class=""> h2 = [Int].sorted(isOrderedBefore:) </span></font><span style="color: rgb(145, 145, 145); font-family: Menlo; font-size: 11px;" class="">// '[Int] -> ((Int, Int) -> Bool) -> [Int]'</span></div></div></div><div class=""><font color="#919191" face="Menlo" style="font-size: 11px;" class=""><br class=""></font></div><div class="">I2: When referring to functions the <b class="">argument labels disappear</b> in the returned function. That's a good thing because there's no generic way to call functions with arguments, and that's why closures too always come without argument labels. We don't, however, lose any clarity at the point where the function reference is passed as an argument because function references always contain the labels in the new notation. (Also, see the future directions for an idea how argument labels can be restored in the function variable.)</div><div class=""><br class=""></div><div class="">I3: Function argument lists are no longer that special and there's no need to notate single-n-tuple argument lists separately from n-argument functions, i.e. <b class=""><a href="https://github.com/apple/swift-evolution/blob/master/proposals/0066-standardize-function-type-syntax.md" class="">SE-0066</a> is not really needed anymore</b>. The new intuition here is that <b class="">it's the function's name that defines how a function can be called</b>, not its type.</div><div class=""><br class=""></div><div class="">I4: Because function variables cannot be overloaded, we can without ambiguity allow all of the following "tuple splatting":</div><div class=""><br class=""></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> <b class="">let</b> tuple1 = (1, 2)</span></font></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> <b class="">let</b> tuple2 = (x: 1, y: 2)</span></font></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> <b class="">let</b> tuple3 = (a: 1, b: 2)</span></font></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> </span><b style="font-size: 11px;" class="">let</b><span style="font-size: 11px;" class=""> y1 = foo(tuple1) </span><font color="#919191" style="font-size: 11px;" class="">// Not a "tuple splat", calls #4 as normal.</font></font></div><div class=""><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> <b class="">let</b> y2 = foo(tuple2)</span></font><span style="font-family: Menlo; font-size: 11px;" class=""> </span><font color="#919191" face="Menlo" style="font-size: 11px;" class="">// Not a "tuple splat", calls #4 as normal.</font></div></div><div class=""><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> <b class="">let</b> y3 = foo(tuple3)</span></font><span style="font-family: Menlo; font-size: 11px;" class=""> </span><font color="#919191" face="Menlo" style="font-size: 11px;" class="">// Not a "tuple splat", calls #4 as normal.</font></div></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> </span></font><b style="font-family: Menlo; font-size: 11px;" class="">let</b><font face="Menlo" class=""><span style="font-size: 11px;" class=""> y4 = foo(_:)(1, 2) </span></font><font color="#919191" face="Menlo" style="font-size: 11px;" class="">// Not a "tuple splat", calls the reference to #4 as normal.</font></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> </span></font><b style="font-family: Menlo; font-size: 11px;" class="">let</b><font face="Menlo" class=""><span style="font-size: 11px;" class=""> y5 = foo(_:)((1, 2)) </span></font><font color="#919191" face="Menlo" style="font-size: 11px;" class="">// "Tuple splat", calls #4.</font></div><div class=""><span style="font-family: Menlo; font-size: 11px;" class=""> <b class="">let</b> y6 = foo(_:)(((1, 2))) <font color="#919191" class="">// </font></span><font color="#919191" class=""><span style="font-family: Menlo; font-size: 11px;" class="">"Tuple splat", calls #4.</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px;" class="">Nothing special here, just an unnecessary pair of parens.</span></font></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> </span></font><b style="font-family: Menlo; font-size: 11px;" class="">let</b><font face="Menlo" class=""><span style="font-size: 11px;" class=""> y7 = foo(_:)(tuple1) <font color="#919191" class="">// </font><font color="#919191" class="">"Tuple splat", calls #4.</font></span></font></div><div class=""><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> </span></font><b style="font-family: Menlo; font-size: 11px;" class="">let</b><font face="Menlo" class=""><span style="font-size: 11px;" class=""> y8 = foo(_:)(tuple2) <font color="#919191" class="">// </font><font color="#919191" class="">"Tuple splat", calls #4. The labelled tuple type is compatible with '(Int, Int)'.</font></span></font></div></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> </span></font><b style="font-family: Menlo; font-size: 11px;" class="">let</b><font face="Menlo" class=""><span style="font-size: 11px;" class=""> z1 = foo(x:y:)(tuple1) </span></font><b style="font-family: Menlo; font-size: 11px;" class="">as</b><font face="Menlo" class=""><span style="font-size: 11px;" class=""> Int </span></font><font color="#919191" face="Menlo" style="font-size: 11px;" class="">// "Tuple splat", calls #5 because the return type is explicitly 'Int'.</font></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> </span></font><b style="font-family: Menlo; font-size: 11px;" class="">let</b><font face="Menlo" class=""><span style="font-size: 11px;" class=""> z2 = foo(x:y:)(tuple2) </span></font><b style="font-family: Menlo; font-size: 11px;" class="">as</b><font face="Menlo" class=""><span style="font-size: 11px;" class=""> Int </span></font><font color="#919191" face="Menlo" style="font-size: 11px;" class="">// "Tuple splat", calls #5. The labels don't really matter here.</font></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> </span></font><b style="font-family: Menlo; font-size: 11px;" class="">let</b><font face="Menlo" class=""><span style="font-size: 11px;" class=""> z3 = foo(x:y:)(tuple3) </span></font><b style="font-family: Menlo; font-size: 11px;" class="">as</b><font face="Menlo" class=""><span style="font-size: 11px;" class=""> Int </span></font><font color="#919191" face="Menlo" style="font-size: 11px;" class="">// "Tuple splat", calls #5. Like above, any tuple labels are compatible in the call.</font></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> </span></font><b style="font-family: Menlo; font-size: 11px;" class="">let</b><font face="Menlo" class=""><span style="font-size: 11px;" class=""> z4 = (foo(x:y:) </span></font><b style="font-family: Menlo; font-size: 11px;" class="">as</b><font face="Menlo" class=""><span style="font-size: 11px;" class=""> (Int, Int) -> Bool)(tuple3) </span></font><font color="#919191" face="Menlo" style="font-size: 11px;" class="">// Here's another way to explicitly pick up the overload.</font></div><div class=""><br class=""></div><div class=""><b class="">Future directions</b></div><div class=""><br class=""></div><div class="">F1: In this proposal, I made a difference between function identifier names and variable identifier names. However, it could be well allowed to use function-like names for function variables when clarity is needed. Then calling a block would require the argument labels just like functions:</div><div class=""><br class=""></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> <b class="">let</b> <font color="#9929bd" class="">block(value:)</font> = {value <b class="">in</b> ...}</span></font></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> block(value: 1)</span></font></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""><br class=""></span></font></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> <b class="">func</b> foo(_ <font color="#9929bd" class="">isOrderedBefore(lhs:rhs:)</font>: (Int, Int) -> Bool) {</span></font></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> let x = isOrderedBefore(lhs: 1, rhs: 2)</span></font></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> }</span></font></div><div class=""><br class=""></div><div class="">F2: The following idea probably divides opinions, but because function variables are unambiguous, we could even allow calling them <i class="">without</i> parentheses like in Haskell. That would open up many doors to currying and building highly composable functional libraries:</div><div class=""><br class=""></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> <b class="">let</b> f = {x <b class="">in</b> ...}</span></font></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> </span><b style="font-size: 11px;" class="">let</b><span style="font-size: 11px;" class=""> y = f 1 </span><font color="#919191" style="font-size: 11px;" class="">// calls 'f' with an 'Int'</font></font></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> </span><b style="font-size: 11px;" class="">let</b><span style="font-size: 11px;" class=""> z = f (1, 2) </span><font color="#919191" style="font-size: 11px;" class="">// calls 'f' with an '(Int, Int)'</font></font></div><div class=""><br class=""></div><div class="">F3: And if that was allowed, maybe it could be possible to define functions with variable-like names and currying too, but now I'm getting too far. I think the proposal is worth considering even if we never go to the direction of Haskell in this way.</div><div class=""><br class=""></div><div class="">— Pyry</div><div class=""><br class=""></div></body></html>