Julia still uses a compiler to do optimization passes. In order for the compiler to replace some of the calculations you sometimes need to help the compiler prove the values or functions will not change.
Your questions are heading in the direction of constant propagation. You may want to start a new post specifically on that topic to get the best responses.