I always assumed constants to be good, obedient variables that are only set once, and thereafter never change. They are reliable and… well… constant!
However, the term “compile-time constant” seems to pop up quite a bit.
Does this mean that rather than treat references to the constant as references to a variable, Flash goes in (at least for numbers, booleans, and strings) and during the compiling replaces all the references to the constant variable with those actual values?
For instance, this line during “edit mode”:
stage.addEventListener(MouseEvent.CLICK, onClick);
during compile time, the Flash FIRST replaces it to this:
stage.addEventListener(“click”, onClick);
and AFTER that finishes the compiling into bytecode?
This method would be a little faster since it doesn’t need to access the constant as a variable, but instead has the actual value, which is a fraction of a second saved, but it can add up in the long run.
Is this what happens or am I way off? Why otherwise would there be the term “Compile-time constant”, and what does that refer to?