January 2020
Intermediate to advanced
532 pages
13h 31m
English
The compiler has a lot more freedom when dealing with constants because of the following:
This will become clear after we look into some simple examples.
Let's take a look at the following function:
function constant_folding_example() a = 2 * 3 b = a + 1 return b > 1 ? 10 : 20end
If we just follow the logic, then it is not difficult to see that it always returns a value of 10. Let's just unroll it quickly here:
From the compiler's perspective, the a variable can be inferred as a constant ...
Read now
Unlock full access