Description of the feature
Basically we need to do constant folding and we need to remove branches that rely exclusively on constants to determine the conditional jump. Essentially optimize if 1 {println("hi");} to println("hi");
This would also allow for bounds checking at compile time of constant expressions.
Examples of usage
my_array[T::SIZEOF * 2] // no longer generates a runtime check!
Possible issues that may make this feature difficult to implement
we need to create an is_constant_expression(self) -> bool property on all ast nodes. Defaults to false.
The math may also be slow in python. So certain constant folding would only be done in builds with --release (once added).
Description of the feature Basically we need to do constant folding and we need to remove branches that rely exclusively on constants to determine the conditional jump. Essentially optimize
if 1 {println("hi");}
toprintln("hi");
This would also allow for bounds checking at compile time of constant expressions. Examples of usage
Possible issues that may make this feature difficult to implement we need to create an
is_constant_expression(self) -> bool
property on all ast nodes. Defaults to false. The math may also be slow in python. So certain constant folding would only be done in builds with--release
(once added).