Possible 'bool' type for NOLOL #51
Labels
backlog
Good idea but bad effort to value ratio right now
enhancement
New feature or request
nolol
Issues only regarding NOLOL
In addition to #48.
Possibly add a
bool
type, used to differentiate truthy number variables from number variables used for arithmetic.This would allow for more optimisations in the future and could raise errors when
num
type variables are used for logic, and whenbool
type variables are used for arithmetic.This would mean code such as
would not be valid, however,
would be.
Any
if x != 0 then ... end
can still be compiled toif x then ... end
.Vise versa,
bool
type variables should not be allowed to be used for arithmetic, as the value in them is only defined by zero or non-zero.All comparisons and logical expressions should return a bool type.
This way, if the programmer wants to perform boolean arithmetic, for example,
x += a or b
, they will have to explicitly state this, i.e.x += (Num)(a or b)
.This will let the compiler know that
a or b
cannot be optimised toa+b
, as the programmer wants the0
or1
number value, as opposed to the boolean truthy value ofa+b
.(Optionally,
bool
values could be used for arithmetic without casting or errors raised, and instead, detect arithmetic performed on bool values and eliminate any arithmatic optimisations used.)Thank you.
The text was updated successfully, but these errors were encountered: