UCIDataScienceInitiative / IntroToJulia

A Deep Introduction to Julia for Data Science and Scientific Computing
http://ucidatascienceinitiative.github.io/IntroToJulia/
MIT License
252 stars 87 forks source link

`const` is not about types #34

Open JeffBezanson opened 6 years ago

JeffBezanson commented 6 years ago

The WhyJulia page states that "const is about types, it acts slightly differently than one would expect. const is a declaration that the type of a will be constant, not the value". This is completely false. The compiler indeed assumes that constants will not change value. This is why we print a warning. We don't just print warnings for the hell of it; if you see a warning something is definitely wrong. In this case your program could break in all kinds of ways, but we allow it for convenience to reduce the need to restart julia.

ChrisRackauckas commented 6 years ago

Yes, I was wrong about this 2 years ago and haven't changed it. Some old blog posts might have this too. I'll get this fixed.