Currently, expr uses only string values internally. This means that for an expression like 1 + 2 + 9 is evaluated as follows:
- Get the strings
"1" and "2"
- Parse them into integers
1 and 2
- Add them to get
3
- Turn
3 into the string "3"
- Parse
"3" back into the integer 3
- Parse
"9" into 9
- Add them to get
12
- Turn
12 into the string "12"
That's a lot of parsing and stringifying. Instead we could have an enum that can contain either an integer or a string which can be turned into the desired value.
Currently,
expruses only string values internally. This means that for an expression like1 + 2 + 9is evaluated as follows:"1"and"2"1and233into the string"3""3"back into the integer3"9"into91212into the string"12"That's a lot of parsing and stringifying. Instead we could have an
enumthat can contain either an integer or a string which can be turned into the desired value.