When we do this, why special-case this for numbers? The proposal doesn’t define numbers, just syntax, and the syntax is not particularly number-like. It starts with a digit, but after that, we have a sequence of numbers or letters, so it’s a (runtime, modulo macro and suitable datatypes) literal for any alpha-numeric string that starts with a digit, and can contain
'.''s to any target type that defines a parser.
This would allow for many different ways to write numbers (even IP addresses would be covered!).
Would it though? I can see how this covers IPv4 addresses only. We could quickly also allow “:” to also be able to cover IPv6 address, but the allowed character set starts to look pretty arbitrary.
Also, should the candiate syntax start with a leading optional
Some examples you could do with the proposal, which are neat and scary and I’m not sure whether they’re more neat than scary:
val coffeetime: LocalTime = 2.20PM
val birthdate: LocalDate = 20.06.1982
val lausanne: WGS84 = 46.519962N6.633597E495A
or even declare some arbitrary binary encoding for any datatype, base64 encoded, and prefixed with a zero.
Some examples of things you can’t do with this proposal
val quarter: Fraction = 1/4
val complex: Complex = 2+2i
val notalot: Double = 2e-20
val lausanneLat: Latitude = 46°31'11.8632''N
I can’t entirely see the justification for the distinction of what should and/or shouldn’t be allowed.