<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br></div><div id="AppleMailSignature"><blockquote type="cite" __apple_fixed_attribute="true"><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 &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; 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>&nbsp;—&nbsp;foo(_:),&nbsp;foo(bar:),&nbsp;foo(bar:baz:)&nbsp;— 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);">&nbsp; &nbsp; func foo() {} &nbsp;// no compound syntax for this one :(</span></font></div><div><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; func foo(_ bar: Int) {} &nbsp;// foo(_:)</span></font></div><div><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; func foo(bar: Int) {} &nbsp;// foo(bar:)</span></font></div><div><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; func foo(bar: String, baz: Double) {} &nbsp;// 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 () -&gt; 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&nbsp;<a href="https://bugs.swift.org/browse/SR-3550">SR-3550</a>&nbsp;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,&nbsp;<b>I'd like to propose&nbsp;foo(:)&nbsp;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&nbsp;foo(bar:)&nbsp;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,&nbsp;[:].</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><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&nbsp;#selector(foo(:))and&nbsp;@selector(foo)&nbsp;is not quite as obvious as between&nbsp;#selector(foo(_:))and&nbsp;@selector(foo:).</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);"><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&nbsp;<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></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 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="gmail_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><blockquote type="cite"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span></font></blockquote></div></body></html>