<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="">Le 13 févr. 2016 à 15:29, David Waite via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; a écrit :</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Erica,</div><div class=""><br class=""></div><div class="">The current spec has the following line:</div><div style="font-size: 8px;" class=""><br style="font-size: 8px;" class=""></div><div style="font-size: 8px;" class=""><blockquote type="cite" class="" style="font-size: 8px;"><div class="" style="font-size: 8px;"><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-size: 8px;"><div class="" style="font-size: 8px;"><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 12px; background-color: rgb(255, 255, 255);"><pre class="" style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 10px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; padding: 16px; background-color: rgb(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: normal; word-break: normal;"><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">static</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">staticFunc2</span>() { <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> foo <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>Tails } <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// requires leading dot</span></pre></div></div></div></div></blockquote></div><div class="">The leading dot requirement does not exist today for references to static properties and functions from a static function.</div></div></div></blockquote><div><br class=""></div>After focusing on this line and on the error we get back when trying it now in playground, I no longer see the reported inconsistent as such, but just as a clash of two permissible syntax, which if changed as proposed will just swap an inconsistency for another one.</div><div><br class=""></div><div>For those wondering, the reported error is: type of expression is ambiguous without more context</div><div><div><br class=""></div><div>The shorthand syntax is to be used when the compiler, and the programmer knows what the type is. In the above example, why should the compile infer that variable foo is of type Coin. It would make more sense for that particular function to be:</div><div><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">static</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> staticFunc2() { <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> foo = <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Coin</span>.Tails }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">static</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> staticFunc2() { <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> foo:<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Coin</span> = .Tails }</div><div>&nbsp;</div><div>And be consistent with (both at a global scope or as static inside the enum):</div><div><br class=""></div><div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> firstCoin:<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Coin</span> = .H<span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">eads</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> secondCoin = <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Coin</span>.T<span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">ails</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="color: rgb(187, 44, 162);" class="">let</span>&nbsp;thirdCoin = .Heads <span style="color: rgb(0, 132, 0);" class="">// not allowed</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures; color: #008400" class=""><br class=""></span></div></div><div>The apparent inconsistency seems to stem from the compiler doing an implicit equivalent of:</div><div><br class=""></div><div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> heads = <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Coin</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">heads</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> tails = <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Coin</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">tails</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class=""><br class=""></span></div></div><div class="">If one define these on its own at a global level, the same inconsistent use of the leading dot is present everywhere.</div><div class=""><br class=""></div><div class="">I’m thinking that the proposal as stated "mandate leading dot" is wrong, it should be redone as "prevent direct access to the implicit static let auto-generated for the enum case within the enum declaration". Unfortunately, I do not know if there are legit use of this implicit static let in the wild.</div><div class=""><br class=""></div><div class="">This way, for the staticFunc2 we get:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="color: rgb(187, 44, 162);" class="">static</span>&nbsp;<span style="color: rgb(187, 44, 162);" class="">func</span>&nbsp;staticFunc2() {&nbsp;<span style="color: rgb(187, 44, 162);" class="">let</span>&nbsp;foo =&nbsp;<span style="color: rgb(79, 129, 135);" class="">Coin</span>.Tails } &nbsp;<span style="color: rgb(0, 132, 0);" class="">// Acceptable</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="color: rgb(187, 44, 162);" class="">static</span>&nbsp;<span style="color: rgb(187, 44, 162);" class="">func</span>&nbsp;staticFunc2() {&nbsp;<span style="color: rgb(187, 44, 162);" class="">let</span>&nbsp;foo:<span style="color: rgb(79, 129, 135);" class="">Coin</span>&nbsp;= .Tails } <span style="color: rgb(0, 132, 0);" class="">// Acceptable</span></div></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="color: rgb(187, 44, 162);" class="">static</span>&nbsp;<span style="color: rgb(187, 44, 162);" class="">func</span>&nbsp;staticFunc2() {&nbsp;<span style="color: rgb(187, 44, 162);" class="">let</span>&nbsp;foo =&nbsp;Tails } &nbsp;<span style="color: rgb(0, 132, 0);" class="">// New error, no longer accessible</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="color: rgb(187, 44, 162);" class="">static</span>&nbsp;<span style="color: rgb(187, 44, 162);" class="">func</span>&nbsp;staticFunc2() {&nbsp;<span style="color: rgb(187, 44, 162);" class="">let</span>&nbsp;foo&nbsp;= .Tails }&nbsp;<span style="color: rgb(0, 132, 0);" class="">// Current error, ambiguous</span></div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Dany</div><div class=""><br class=""></div></div><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Is your proposal to:</div><div class="">- require a dot in front of static properties/functions in this case as well for consistency across all static things</div><div class="">- require a dot only in front of the case statements, to promote consistency only for use of cases within an enum</div><div class="">- or, do you wish to change your mind about this particular case?</div><div class=""><br class=""></div><div class="">-DW</div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Feb 13, 2016, at 12:31 PM, Erica Sadun 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=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">No. The wildcard match does not require a dot prefix.</div><div class=""><br class=""></div><div class="">-- E</div><div class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Feb 13, 2016, at 10:40 AM, Paul Ossenbruggen 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=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I am assuming there would be no dot in front of _?&nbsp;<div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div style="font-size: 17px;" class="">switch value {</div><div style="font-size: 17px;" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>case .A: “A”</div><div style="font-size: 17px;" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>case .B: “B”</div><div style="font-size: 17px;" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>case ._:”D” // this is not correct?</div><div style="font-size: 17px;" class="">}</div></div><div style="font-size: 17px;" class=""><br class=""></div><div style="font-size: 17px;" class=""><br class=""></div><div class=""><div class=""><blockquote type="cite" class=""><div class="">On Feb 13, 2016, at 9:18 AM, Joseph Lord 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=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class=""></div><div class="">+1</div><div class=""><br class=""></div><div class="">Didn't even know it was legal. Definitely increases consistency and simplifies the language.&nbsp;</div><div class=""><br class=""></div><div class="">J</div><div class=""><br class="">On Feb 12, 2016, at 3:00 AM, Erica Sadun via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><a href="https://gist.github.com/erica/e0b8a3a22ab716a19db4" class="">https://gist.github.com/erica/e0b8a3a22ab716a19db4</a><div class=""><br class=""></div><div class=""><h1 style="box-sizing: border-box; font-size: 2.25em; margin-right: 0px; margin-bottom: 16px; margin-left: 0px; line-height: 1.2; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(238, 238, 238); color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255); margin-top: 0px !important;" class="">Requiring Leading Dot Prefixes for Enum Instance Member Implementations</h1><ul style="box-sizing: border-box; padding: 0px 0px 0px 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);" class=""><li style="box-sizing: border-box;" class=""><br class=""></li></ul></div></div></blockquote></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></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=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></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>