# Const variables

**URL:** <https://discourse.julialang.org/t/const-variables/42956>\
**Category:** New to Julia\
**Tags:** constants\
**Created:** [July 12, 2020, 5:40pm UTC](https://discourse.julialang.org/t/const-variables/42956 "2020-07-12T17:40:58Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [July 13, 2020, 2:19am UTC](https://discourse.julialang.org/t/const-variables/42956/13 "2020-07-13T02:19:15Z")

</div>

I am sure @dpsanders is much more knowledgeable than I am, but I find necessary to point that

> The word `const` is really a misnomer. It is not that the variable is constant. It is the variable type that is constant, which is quite different.

Is just completely wrong. The **binding** is constant, not the _type_. What difference this make? Exactly what @dpsanders pointed out, but trying to explain more exhaustively I would say: if the binding `var1` is constant, then you cannot assign a new value/object for `var1` (_even of the same type_), you can change a mutable field inside that value, but you cannot ever replace the _entire_ object inside `var1` by another.

This is: if `tmp1` is an array, then you can add, remove, and replace elements; but you cannot never replace the original array by a brand new array (for example, to “empty” the array temporarily while keeping the old array in an auxiliary variable, with the intent of putting it back after, without having to make any copies, a `swap` basically); it is not the type that is fixed, it is that initial object (which can have mutable fields) that is fixed there forever. If it is an `Int` like in your example, this means you cannot never change that value (because an `Int` has no mutable fields inside it you can change). That name will point to the same ‘memory position’/reference/value its entire existence.

---

_[View the full topic](https://discourse.julialang.org/t/const-variables/42956)._
