<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Apr 6, 2017, at 7:02 AM, Xiaodi Wu 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=""><div class="">Given that \foo(bar:baz:) will work, and that \foo() will be unambiguously distinguished from foo(), I think that would be the only logical result.</div></div></blockquote><div><br class=""></div><div>Agree. &nbsp;It seem like this would fit nicely into the revision of SE-0042 that Doug mentioned.</div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><br class=""></div><div class=""><br class=""><div class="gmail_quote"><div class="">On Thu, Apr 6, 2017 at 00:40 Jacob Bandes-Storch via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_msg">Now that escaping with \ has been proposed for KeyPaths, this makes me wonder whether it would be appropriate to use "\foo()" rather than "foo(_)"/"foo(:)" ?&nbsp; It still feels a bit strange, as \foo() looks like escaping the <b class="gmail_msg">result</b>&nbsp;of a call.</div><div class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div class="gmail_extra gmail_msg">
<br class="gmail_msg"><div class="gmail_quote gmail_msg">On Sat, Feb 25, 2017 at 1:43 PM, David Hart <span class="gmail_msg">&lt;<a href="mailto:david@hartbit.com" class="gmail_msg" target="_blank">david@hartbit.com</a>&gt;</span> wrote:<br class="gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg"><br class="gmail_msg"><div class="gmail_msg"><span class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On 25 Feb 2017, at 00:56, Jordan Rose via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_-847555223454010977m_-4474339546849733160Apple-interchange-newline gmail_msg"><div class="gmail_msg"><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg">I don't have a <i class="gmail_msg">good</i>&nbsp;answer for this, but I'll vote <i class="gmail_msg">against</i>&nbsp;'foo(:)' because that's what a lot of people think the name of 'foo(_:)' should be. I'd rather be able to offer fix-its for that even when you have both 'foo()' and 'foo(_:)' defined. I'd rather go with 'foo(_)' despite the tiny ambiguity in pattern contexts.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">(I'm personally in favor of killing unapplied function references altogether in favor of closures, on the grounds that they are overly terse, make type-checking more complicated, and often lead to retain cycles. Then we'd only need this for #selector, and it's perfectly unambiguous to use 'foo()' there. But I wasn't planning to fight that particular battle now, and it is rather annoying to require the 'as' in the meantime.)</div></div></div></blockquote><div class="gmail_msg"><br class="gmail_msg"></div></span><div class="gmail_msg">It is potentially going to be hard to fight that battle. I think a lot of functional/Haskell people love them and would be sad to see them go away (I plead guilty). But it isn’t a well known part of the language so I don’t think the general community would miss it.</div><br class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"><span class="gmail_msg"><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg">Jordan</div><div class="gmail_msg"><br class="gmail_msg"></div><br class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Feb 21, 2017, at 23:05, Jacob Bandes-Storch &lt;<a href="mailto:jtbandes@gmail.com" class="gmail_msg" target="_blank">jtbandes@gmail.com</a>&gt; wrote:</div><br class="m_-847555223454010977m_-4474339546849733160Apple-interchange-newline gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">Evolutioniers,</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><b class="gmail_msg">Compound name syntax</b>&nbsp;— <font face="monospace, monospace" class="gmail_msg">foo(_:)</font>, <font face="monospace, monospace" class="gmail_msg">foo(bar:)</font>, <font face="monospace, monospace" class="gmail_msg">foo(bar:baz:)</font> — 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.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div class="gmail_msg"><font face="monospace, monospace" class="gmail_msg">&nbsp; &nbsp; func foo() {} &nbsp;// no compound syntax for this one :(</font></div><div class="gmail_msg"><font face="monospace, monospace" class="gmail_msg">&nbsp; &nbsp; func foo(_ bar: Int) {} &nbsp;// foo(_:)</font></div><div class="gmail_msg"><font face="monospace, monospace" class="gmail_msg">&nbsp; &nbsp; func foo(bar: Int) {} &nbsp;// foo(bar:)</font></div><div class="gmail_msg"><font face="monospace, monospace" class="gmail_msg">&nbsp; &nbsp; func foo(bar: String, baz: Double) {} &nbsp;// foo(bar:baz:)</font></div></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Given these four functions, only the first one has no compound name syntax. And the simple reference "<font face="monospace, monospace" class="gmail_msg">let myfn = foo</font>" is ambiguous because it could refer to any of the four. A workaround is to specify a contextual type, e.g. "<font face="monospace, monospace" class="gmail_msg">let myfn = foo as () -&gt; Void</font>".</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">I filed&nbsp;<a href="https://bugs.swift.org/browse/SR-3550" class="gmail_msg" target="_blank">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.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">To kick off the discussion,&nbsp;<b class="gmail_msg">I'd like to propose <font face="monospace, monospace" class="gmail_msg">foo(:)</font>&nbsp;for nullary functions.</b></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Advantages:</div><div class="gmail_msg">- the colon marks a clear similarity to the&nbsp;<font face="monospace, monospace" class="gmail_msg">foo(bar:)</font> form when argument labels are present.</div><div class="gmail_msg">- cutely parallels the empty dictionary literal, <font face="monospace, monospace" class="gmail_msg">[:]</font>.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Disadvantages:</div><div class="gmail_msg">- violates intuition about one-colon-per-argument.</div><div class="gmail_msg">- the parallel between <font face="monospace, monospace" class="gmail_msg">#selector(foo(:))</font> and <font face="monospace, monospace" class="gmail_msg">@selector(foo)</font>&nbsp;is not quite as obvious as between <font face="monospace, monospace" class="gmail_msg">#selector(foo(_:))</font> and&nbsp;<font face="monospace, monospace" class="gmail_msg">@selector(foo:)</font>.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">For the sake of discussion, another option would be <font face="monospace, monospace" class="gmail_msg"><b class="gmail_msg">foo(_)</b></font>. 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).</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Looking forward to everyone's bikeshed color ideas,<br clear="all" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg m_-847555223454010977m_-4474339546849733160gmail_signature"><div class="gmail_msg"><div class="gmail_msg">Jacob<br class="gmail_msg"></div></div></div></div>
</div></div></div>
</div></blockquote></div><br class="gmail_msg"></div></span><span class="gmail_msg">_______________________________________________<br class="gmail_msg">swift-evolution mailing list<br class="gmail_msg"><a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg"></span></div></blockquote></div><br class="gmail_msg"></div></blockquote></div><br class="gmail_msg"></div></div></div>
_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
</blockquote></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="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>