[swift-evolution] [Pitch] Allow numerical keywords in member references

David Sweeris davesweeris at mac.com
Thu Mar 9 16:52:54 CST 2017

> 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

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

More information about the swift-evolution mailing list