<div dir="ltr">On Sat, Apr 8, 2017 at 7:15 PM, Brent Royal-Gordon via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div><span class="gmail-"><blockquote type="cite"><div>On Feb 22, 2017, at 12:24 PM, Jacob Bandes-Storch via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="gmail-m_7678847237088578534Apple-interchange-newline"><div><span style="font-family:helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline">There were some opinions on Slack that we should simply change `foo` so that it can *only* refer to the nullary version.</span><br style="font-family:helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"></div></blockquote><div><br></div></span><div>I think this is the right solution. Eventually we want to get to the point where parameter labels are part of a compound name; at that point, it&#39;d be natural for a zero-argument function to just have its name be the base name.</div></div></div></blockquote><div><br></div><div>With the sigil, this seems like a half-way solution. If we are to remove base name-only lookups, the zero-argument function can be unambiguously spelled `\foo()` and we can leave `\foo` to refer only to variables named &quot;foo&quot; without a compound name.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div><span class="gmail-"><br><blockquote type="cite"><div><span style="font-family:helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline">That&#39;d be a source-breaking change,</span></div></blockquote><div><br></div></span><div>We can always support looking up members by base name only as an unprincipled shorthand. (But to tell the truth, I&#39;d prefer to just break them.)</div><span class="gmail-"><br><blockquote type="cite"><div><span style="font-family:helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline">but I&#39;m also not sure whether it&#39;s even solve the problem — is it true you might still have both a function and a variable named foo accessible in the same scope?</span></div></blockquote></span></div><div><br></div><div>The simple version is illegal:</div><div><br></div><div><span class="gmail-m_7678847237088578534Apple-tab-span" style="white-space:pre-wrap">        </span>Welcome to Apple Swift version 3.1 (swiftlang-802.0.41 clang-802.0.36). Type :help for assistance.<br><span class="gmail-m_7678847237088578534Apple-tab-span" style="white-space:pre-wrap">        </span>  1&gt; struct X { var x: Int; func x() {} }<br><span class="gmail-m_7678847237088578534Apple-tab-span" style="white-space:pre-wrap">        </span>error: repl.swift:1:29: error: invalid redeclaration of &#39;x()&#39;<br><span class="gmail-m_7678847237088578534Apple-tab-span" style="white-space:pre-wrap">        </span>struct X { var x: Int; func x() {} }<br><span class="gmail-m_7678847237088578534Apple-tab-span" style="white-space:pre-wrap">        </span>                            ^<br><span class="gmail-m_7678847237088578534Apple-tab-span" style="white-space:pre-wrap">        </span><br><span class="gmail-m_7678847237088578534Apple-tab-span" style="white-space:pre-wrap">        </span>repl.swift:1:16: note: &#39;x&#39; previously declared here<br><span class="gmail-m_7678847237088578534Apple-tab-span" style="white-space:pre-wrap">        </span>struct X { var x: Int; func x() {} }<br><span class="gmail-m_7678847237088578534Apple-tab-span" style="white-space:pre-wrap">        </span>               ^<br></div></div></blockquote><div><br></div><div>No, but this is legal:</div><div><br></div><div>```</div><div><div>struct S {</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>var foo: Int = 42</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>func foo(_ bar: Int = 42) {</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>print(&quot;Hello, world!&quot;)</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>}</div><div>}</div></div><div>```</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div></div><div>I have a sneaking suspicion there actually *are* circumstances where it&#39;s possible—but I think there probably shouldn&#39;t be.</div></div></blockquote><div><br></div><div>There are legitimate designs that might make use of this (see the `ulp` example above); whether it&#39;s wise or not is a different matter.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div>Of the main options discussed—`foo(_)` vs `foo(:)`—I think the underscore is more accurate. It does conflict with pattern matching syntax, but I don&#39;t think you can match a (0-ary) function value against anything anyway, so I don&#39;t think that matters in practice.</div><span class="gmail-HOEnZb"><font color="#888888"><br><div>
<span class="gmail-m_7678847237088578534Apple-style-span" style="border-collapse:separate;font-variant-ligatures:normal;font-variant-east-asian:normal;line-height:normal"><div><div style="font-size:12px">-- </div><div style="font-size:12px">Brent Royal-Gordon</div><div style="font-size:12px">Architechies</div></div></span>

</div>
<br></font></span></div><br>______________________________<wbr>_________________<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" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
<br></blockquote></div><br></div></div>