[swift-evolution] [Pitch] Allow numerical keywords in member references
Derrick Ho
wh1pch81n at gmail.com
Fri Mar 10 07:43:09 CST 2017
-1
Something like `42` will make things confusing.
On Thu, Mar 9, 2017 at 5:53 PM David Sweeris via swift-evolution <
swift-evolution at swift.org> wrote:
>
> On Mar 9, 2017, at 04:40, Ross O'Brien via swift-evolution <
> swift-evolution at swift.org> wrote:
>
> I could see a purpose for identifiers which started numbers but weren't
> entirely numerical.
> e.g.
> enum Dimensions { case `2D`, `3D` }
> enum DiceRoll { case d6, `2d6` }
> func roll(dice: DiceRoll) -> Int { ... }
> roll(.`2d6`)
>
> I'm not sure I see one for identifiers which are entirely numerical.
>
>
> That's certainly a much easier sell... How does "_" fit into this? I know
> `123_456` is a valid integer literal and that `_1` is a valid identifier. I
> don't know if `_1` is a valid integer literal.
>
> I'd *like* to support purely numeric identifiers, but I can't think of a
> way around the ambiguity of `3.0`. Maybe only allow it if the enclosing
> type isn't ExpressibleByIntegerLiteral? It feels more than a bit odd,
> though, to have a property name's validity depend on whether or not it's in
> a ExpressibleByIntegerLiteral type.
>
> - Dave Sweeris
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170310/a6bf7344/attachment.html>
More information about the swift-evolution
mailing list