<div dir="ltr">I'm personally in favor of <font face="monospace, monospace">foo(_)</font>, as the number of colons currently lines up directly with the number of arguments, and it'd be good to keep it that way.<div><br></div><div>In general though I'm very in favor of requiring the parentheses, as the ambiguity between unparenthesized references to functions and properties can be quite confusing/annoying.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 22, 2017 at 6:35 PM, David Hart via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div><br></div><div id="m_7995815828843001064m_-1771258588154260740AppleMailSignature"><span><blockquote type="cite"><font color="#000000"><span style="background-color:rgba(255,255,255,0)"><br>On 22 Feb 2017, at 08:05, Jacob Bandes-Storch via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br><br></span></font></blockquote><blockquote type="cite"><div dir="ltr"><div><font color="#000000"><span style="background-color:rgba(255,255,255,0)">Evolutioniers,</span></font></div><div><font color="#000000"><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font color="#000000"><span style="background-color:rgba(255,255,255,0)"><b>Compound name syntax</b> — foo(_:), foo(bar:), f<wbr>oo(bar:baz:) — is used to disambiguate references to functions. (You might've used it inside a #selector expression.) But there's currently no compound name for a function with no arguments.</span></font></div><div><font color="#000000"><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><div><font color="#000000"><span style="background-color:rgba(255,255,255,0)"> func foo() {} // no compound syntax for this one :(</span></font></div><div><font color="#000000"><span style="background-color:rgba(255,255,255,0)"> func foo(_ bar: Int) {} // foo(_:)</span></font></div><div><font color="#000000"><span style="background-color:rgba(255,255,255,0)"> func foo(bar: Int) {} // foo(bar:)</span></font></div><div><font color="#000000"><span style="background-color:rgba(255,255,255,0)"> func foo(bar: String, baz: Double) {} // foo(bar:baz:)</span></font></div></div><div><font color="#000000"><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font color="#000000"><span style="background-color:rgba(255,255,255,0)">Given these four functions, only the first one has no compound name syntax. And the simple reference "let myfn = foo" is ambiguous because it could refer to any of the four. A workaround is to specify a contextual type, e.g. "let myfn = foo as () -> Void".</span></font></div><div><font color="#000000"><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font color="#000000"><span style="background-color:rgba(255,255,255,0)">I filed <a href="https://bugs.swift.org/browse/SR-3550" target="_blank">SR-3550</a> for this a while ago, and there was some discussion in JIRA about it. I'd like to continue exploring solutions here and then write up a formal proposal.</span></font></div><div><font color="#000000"><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font color="#000000"><span style="background-color:rgba(255,255,255,0)">To kick off the discussion, <b>I'd like to propose foo(:) for nullary functions.</b></span></font></div><div><font color="#000000"><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font color="#000000"><span style="background-color:rgba(255,255,255,0)">Advantages:</span></font></div><div><font color="#000000"><span style="background-color:rgba(255,255,255,0)">- the colon marks a clear similarity to the foo(bar:) form when argument labels are present.</span></font></div><div><font color="#000000"><span style="background-color:rgba(255,255,255,0)">- cutely parallels the empty dictionary literal, [:].</span></font></div><div><font color="#000000"><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font color="#000000"><span style="background-color:rgba(255,255,255,0)">Disadvantages:</span></font></div><div><font color="#000000"><span style="background-color:rgba(255,255,255,0)">- violates intuition about one-colon-per-argument.</span></font></div></div></blockquote><div><span style="background-color:rgba(255,255,255,0)"><br></span></div></span><div><span style="background-color:rgba(255,255,255,0)">This is a big disadvantage for me and will potentially be very surprising for newcomers.</span></div><span style="background-color:rgba(255,255,255,0)"><br></span><blockquote type="cite"><div dir="ltr"><div><font color="#000000"><span style="background-color:rgba(255,255,255,0)">- the parallel between #selector(foo(:))and @<wbr>selector(foo) is not quite as obvious as between #selector(foo(_:))and <wbr>@selector(foo:).</span></font></div><span><div><font color="#000000"><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font color="#000000"><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font color="#000000"><span style="background-color:rgba(255,255,255,0)">For the sake of discussion, another option would be <b>foo(_)</b>. This was my original choice, and I like that the number of colons matches the number of parameters. However, it's a little less obvious as a function reference. It would preclude _ from acting as an actual identifier, and might conflict with pattern-matching syntax (although it appears functions can't be compared with ~= anyway).</span></font></div></span></div></blockquote><div><span style="background-color:rgba(255,255,255,0)"><br></span></div><div><span style="background-color:rgba(255,255,255,0)">This is my favorite syntax so far.</span></div><span><span style="background-color:rgba(255,255,255,0)"><br></span><blockquote type="cite"><div dir="ltr"><font color="#000000"><span style="background-color:rgba(255,255,255,0)">Looking forward to everyone's bikeshed color ideas,<br clear="all"></span></font><div><div class="m_7995815828843001064m_-1771258588154260740gmail_signature"><div dir="ltr"><font color="#000000"><span style="background-color:rgba(255,255,255,0)">Jacob<br></span></font></div></div></div></div></blockquote></span><blockquote type="cite"><font color="#000000"><span style="background-color:rgba(255,255,255,0)">______________________________<wbr>_________________<span><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/mailma<wbr>n/listinfo/swift-evolution</a></span></span></font></blockquote></div></div><br>______________________________<wbr>_________________<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/mailma<wbr>n/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div></div>