Complex Number Literals?
What about expanding the literals to include complex numbers?
Dim x = 12.34+56.78i
' X : Numerics.Complex
At the moment is it being parsed as.
Dim x = (((12.34) + (56.78)) (i))
' x : Double
If i is already defined. Parsing would result in a error. End of statement expected
So I don't think extending parsing to include complex numbers would introduce any issues, related to backwards compatibility.
Argument
But wouldn't this potentially produce code that compiles, if i was a typing error? Previously it wouldn't haven't compiled.
It now would compile (or be inferred) as different type so would introduce compile time errors where it is being used.
BNF
Digit_Zero ::= '0'
Digit_One ::= '1'
Digit_Two ::= '2'
Digit_Three ::= '3'
Digit_Four ::= '4'
Digit_Five ::= '5'
Digit_Six ::= '6'
Digit_Seven ::= '7'
Digit_Eight ::= '8'
Digit_Nine ::= '9'
ZeroToNine ::= Digit_Zero  Digit_One  Digit_Two  Digit_Three  Digit_Four  Digit_Five  Digit_Six  Digit_Seven  Digit_Eight  Digit_Nine
Complex_Symbol ::= 'i'
Digit ::= ZeroToNine
Digits ::= Digit+
Negative_Symbol ::= ''
Positive_Symbol ::= '+'
Sign ::= Negative_Symbol  Positive_Symbol
Integer_Number ::= (Sign)? Digits
Decimal_Point ::= '.'
Float_Part ::= Decimal_Point Digits
Real_Number ::= Integer_Number Float_Part
Complex_Part ::= Real_Number Complex_Symbol
Real_Part ::= Real_Number
Complex_Glue ::= '+'
Complex_Number ::= Real_Part Complex_Glue Complex_Part
Parse Tree
 1 2 . 3 4 +  5 6 . 7 8 i
             
S D1 D2 Dp D3 D4 S+ S D5 D6 DP D7 D8 Si
+ + + +
   
S D+ Dp D+ S+ S D+ DP D+ Si
+ + + +
   
NI NF S+ NI NF Si
+ +
 
NR S+ NR SI
+

NR S+ Ni
+

Nc
