Integer constants should not be restricted to decimals, but include other convenient radixes
Just a plain sequence of digits: 123456789. Do we need support for grouping of thousands or tenthousends as in
million := 1_000_000 ichi_oku := 1_0000_0000or
million := 1,000,000 ichi_oku := 1,0000,0000
? Commas are confusing since some languages use decimal commas instead of decimal points. See also: Stop Putting Commas in Your Numbers.
Space are used to separate expressions, but Unicode's 'NARROW NO-BREAK SPACE (U+202F)' or 'THIN SPACE (U+2009)' might be an alternative, but a dangerous one resulting in different semantics depending on different kinds of white space. Not a good idea.
Only few languages support binaries, and if they do, usually by adding a prefix '0b':
letter := [ 0b00110000, 0b01111000, 0b11001100, 0b11001100, 0b11111100, 0b11001100, 0b11001100, 0b11001100, 0b00000000,] letters := [ 0b00110000111110000011110011111000 0b01111000110011000110000011001100 0b11001100110011001100000011000110 0b11001100111110001100000011000110 0b11111100110001101100000011000110 0b11001100110001101100000011000110 0b11001100110011000110000011001100 0b11001100111110000011110011111000 0b00000000000000000000000000000000,]
it might help to have seperators
letters := [ 0b_00110000_11111000_00111100_11111000 0b_01111000_11001100_01100000_11001100 0b_11001100_11001100_11000000_11000110 0b_11001100_11111000_11000000_11000110 0b_11111100_11000110_11000000_11000110 0b_11001100_11000110_11000000_11000110 0b_11001100_11001100_01100000_11001100 0b_11001100_11111000_00111100_11111000 0b_00000000_00000000_00000000_00000000,]
Octals are typically prefixed with '0' resulting in easy confusion with decimals:
a := 1234; // = 1234 b := 0234; // = 156 c := 0034; // = 28 d := 0004; // = 4 e := 1000; // = 1000
This is awful!
Rust uses the prefix '0o' for octals, so the equivalent code would be
a := 1234; // = 1234 b := 0o234; // = 156 c := 0o034; // = 28 d := 0o004; // = 4 e := 1000; // = 1000
This seems much cleares.
A prefix '0x' or '0X' is common for these. Java allows negative hex numbers like '0xffffFFFF' without giving a '-'.
Fuzion should allow prefixes '0b', '0o', '0d', '0x' for binary, octal, decimal and hexadecimal integer literals, no prefix means the literal is a decimal
The literal may contain '_' separators. If present, the separators must divide the number into groups of equal sizes larger than 1, only the first group might be smaller, even empty if preceded by a prefix..