Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Very welcome changes. Well done to the team.

The 'typed non-const globals' are a welcome syntax update for the sake of consistency with the rest of the language ... but it's worth pointing out that const globals effectively had the same effect, since you actually were allowed to redefine a const-labelled variable, and you were only prohibited from changing their type. Earlier versions of Julia silently ignored such redefinitions, but a warning was added later on whenever a redefinition of a const variable was detected. So I guess the only difference between the two now is that one will issue a warning and the other will not? I don't know if the two also have some hidden performance differences that are not obvious from this post. Regardless, still a small but welcome change nonetheless.



The warning on redefining const globals is important. It's there because when you change a const global, that change may not get picked up in functions that use the variable (since you declared it as const). Using the type annotation prevents the compiler from saving the value of the global in other code and makes it do a lookup at runtime.


Functions can inline global const values and these will not be updated when you change it in a way that emits the warning. So it is not the same, the warning is not there for no reason.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: