<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=""><div class="">I meant “Unless I’m forgetting something”, uh :/</div><br class=""><div class="">
<div class="">— Radek</div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On 27 Feb 2016, at 14:37, Radosław Pietruszewski <<a href="mailto:radexpl@gmail.com" class="">radexpl@gmail.com</a>> 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="">+1, that makes a lot of sense.</div><div class=""><br class=""></div><div class="">Q: Is `case default` in enum context ambiguous? In case I’m forgetting something, `default` is only used in `switch` contexts. So… couldn’t we make the keyword context dependent?</div><br class=""><div class="">
<div class="">— Radek</div>
</div>
<br class=""><div class=""><blockquote type="cite" class=""><div class="">On 26 Feb 2016, at 21:43, Douglas Gregor via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> 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="">Hi all,<div class=""><br class=""></div><div class="">As part of the grand API guidelines discussion, there was a lot of support for using lowerCamelCase for enum cases, because they are values in Swift. One unfortunate wrinkle here is that it’s not at all uncommon to have a case named “Default” for an enumeration. One example pulled randomly from GitHub:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><div class=""><font face="Menlo" class="">enum DispatchQOS {</font></div></div><div class=""><div class=""><font face="Menlo" class=""> case UserInteractive</font></div></div><div class=""><div class=""><font face="Menlo" class=""> case UserInitiated</font></div></div><div class=""><div class=""><font face="Menlo" class=""> case Default</font></div></div><div class=""><div class=""><font face="Menlo" class=""> case Utility</font></div></div><div class=""><div class=""><font face="Menlo" class=""> case Background</font></div></div><div class=""><div class=""><font face="Menlo" class="">}</font></div></div></blockquote><div class=""><br class=""></div><div class="">If we’re lowerCamelCasting enum cases, this becomes:</div><div class=""><br class=""></div><div class=""><blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class=""><div class=""><font face="Menlo" class="">enum DispatchQOS {</font></div><div class=""><font face="Menlo" class=""> case userInteractive</font></div><div class=""><font face="Menlo" class=""> case userInitiated</font></div><div class=""><font face="Menlo" class=""> case `default`</font></div><div class=""><font face="Menlo" class=""> case utility</font></div><div class=""><font face="Menlo" class=""> case background</font></div><div class=""><font face="Menlo" class="">}</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div></blockquote></div><div class="">Note the back-ticks, which are also needed at the call site:</div><div class=""><br class=""></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>func dispatch(priority priority: </font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>dispatch(priority: .`default`) { … }</font></div><div class=""><br class=""></div><div class="">We could allow one to refer to keywords without back-ticks following a “.”, similarly to the way we allow keywords without back-ticks preceding a ‘:’ for argument labels, e.g.:</div><div class=""><br class=""></div><div class=""><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>func dispatch(priority priority: </font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>dispatch(priority: .`default`) { … }</font></div></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class="">One would still need to use back-ticks in the declaration of the case, but at least uses would be back-tick-free. Thoughts?</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>- Doug</div><div class=""><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></div></blockquote></div><br class=""></body></html>