# Does Julia Need a C++ style \`static\` keyword?

**URL:** <https://discourse.julialang.org/t/does-julia-need-a-c-style-static-keyword/29176>\
**Category:** Internals & Design\
**Created:** [September 25, 2019, 8:24pm UTC](https://discourse.julialang.org/t/does-julia-need-a-c-style-static-keyword/29176 "2019-09-25T20:24:33Z")\
**Posts on this page:** 2\
**Page:** 2

<div class="post-metadata">

**Author:** ![essenciary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/essenciary/32/210469_2.png) [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Post date:** [September 26, 2019, 3:29pm UTC](https://discourse.julialang.org/t/does-julia-need-a-c-style-static-keyword/29176/21 "2019-09-26T15:29:41Z")

</div>

> [@dataDiver](#):
>
> If I’m honest I don’t use `const` because I don’t really know how it works. The manual ([Essentials · The Julia Language](https://docs.julialang.org/en/v1/base/base/#const)) says `const` is for global variables **that do not change** - which is most certainly not the same idea as a C++ `static` variables

I’ve had some epic bugs from code which was relying on changing constants. Basically, there is no guarantee that the changes to the constant will propagate everywhere is used (especially true, from my observations, if the functions using the constant are inlined). The manual gives the impression that changing const values is frowned upon, but allowed. But from my experience, it should just be disallowed by the compiler. The behaviour of the code is nondeterministic.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [September 27, 2019, 5:01am UTC](https://discourse.julialang.org/t/does-julia-need-a-c-style-static-keyword/29176/22 "2019-09-27T05:01:28Z")

</div>

I don’t think there is any reason why updating “constants” could not work, similarly to the solution of [#265](https://github.com/JuliaLang/julia/issues/265), it is just that it has not been implemented yet.

Declaring something `const` would then imply that the compiler is free to treat it as such, and changing it (which would ideally happen only in development) would trigger recompilation.

[Previous page](https://discourse.julialang.org/t/does-julia-need-a-c-style-static-keyword/29176.md?page=1)
