[swift-evolution] [Idea] Allowing most keywords after "."

Howard Lovatt howard.lovatt at gmail.com
Sat Feb 27 20:54:36 CST 2016


+1 for lower camel & case _

On Saturday, 27 February 2016, Joel Lopes Da Silva via swift-evolution <
swift-evolution at swift.org> wrote:

> I agree with Michel that we might as well standardize on "case _" instead
> of “default”. This way, we wouldn’t even require the back-ticks in the enum
> case definition in this one case.
>
> But I also like Doug’s proposal, because it could apply nicely to other
> language keyword (such as switch).
>
> --
> Joel Lopes Da Silva
>
>
> On Feb 26, 2016, at 5:12 PM, Michel Fortin via swift-evolution <
> swift-evolution at swift.org
> <javascript:_e(%7B%7D,'cvml','swift-evolution at swift.org');>> wrote:
>
> Le 26 févr. 2016 à 15:43, Douglas Gregor via swift-evolution <
> swift-evolution at swift.org
> <javascript:_e(%7B%7D,'cvml','swift-evolution at swift.org');>> a écrit :
>
>
> Hi all,
>
> 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:
>
> enum DispatchQOS {
>   case UserInteractive
>   case UserInitiated
>   case Default
>   case Utility
>   case Background
> }
>
>
> If we’re lowerCamelCasting enum cases, this becomes:
>
> enum DispatchQOS {
>   case userInteractive
>   case userInitiated
>   case `default`
>   case utility
>   case background
> }
>
> Note the back-ticks, which are also needed at the call site:
>
> func dispatch(priority priority:
>
> dispatch(priority: .`default`) { … }
>
> 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.:
>
> func dispatch(priority priority:
>
> dispatch(priority: .`default`) { … }
>
> One would still need to use back-ticks in the declaration of the case, but
> at least uses would be back-tick-free. Thoughts?
>
>
> Another idea is to replace the keyword default with something else. The
> only place it can occur is within a switch statement, right? We already
> have a synonym: case _
>
> --
> Michel Fortin
> https://michelf.ca
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> <javascript:_e(%7B%7D,'cvml','swift-evolution at swift.org');>
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
>

-- 
-- Howard.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160228/a698533e/attachment.html>


More information about the swift-evolution mailing list