|14:30||Improved integer syntax. [55a5b57c3b]. check-in: 946bd10827 user: robin.hansen tags: trunk|
|09:26||• New ticket [55a5b57c3b] 0.3.0: Integer improvements. artifact: 4a57ca5977 user: robin.hansen|
|Title:||0.3.0: Integer improvements|
robin.hansen added on 2021-08-10 09:26:00:
The current support for integers in Stabel is quite limited. You can perform basic operations like equality, addition, subtraction, multiplication and division, as well as two-three additional operations defined in the standard library.
Note that there is no comparison functions, no bitwise functions or more advanced math functions.
In addition, the only form of integer literals currently supported is positive integers in base-10 format.
If Stabel want to be a general purpose language, the support for integers has to be improved.
When it comes to improving literal formats, we'll stick to what's known to work well in other languages.
For negative integers in base 10, I propose the negative sign being postfix like so: 100-
This is different from most other languages, but in most other languages the minus symbol isn't a valid function name, which it is in Stabel. By having the minus sign as postfix we avoid complicated rules in the parser for what constitutes a number and what constitutes a function.
When it comes to supporting additional operations, I propose that extra functionality is moved to math and bitwise modules depending on what categories those fit in. This requires some refactoring in the compiler around handling builtins, but is something that would likely have to be done anyway for supporting strings and arrays.
I also propose that in addition to supporting all intrinsic integer operations of the wasm spec, that we try to support all math operations available in the Elm core library for integers. If nothing else, we should at least be as good as Elm after the next major release.