# Redefining structs without restart?

**URL:** <https://discourse.julialang.org/t/redefining-structs-without-restart/50826>\
**Category:** Internals & Design\
**Created:** [November 24, 2020, 5:08pm UTC](https://discourse.julialang.org/t/redefining-structs-without-restart/50826 "2020-11-24T17:08:10Z")\
**Posts on this page:** 1\
**Showing post:** 37

<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:** [November 26, 2020, 2:17am UTC](https://discourse.julialang.org/t/redefining-structs-without-restart/50826/37 "2020-11-26T02:17:19Z")

</div>

> [@Sukera](#):
>
> Note that you’ve misunderstood the semantics of `const` - it doesn’t mean that `c` will never change value, it means that `c` will never change _type_ . It’s also not a guarantee the compiler gives you, it’s a _promise you make to the compiler_ about not changing value or type

> [@Will Julia ever fix its "using ..." latency problems?](https://discourse.julialang.org/t/will-julia-ever-fix-its-using-latency-problems/50659/93):
>
> As I see it, `const` is a _guarantee_ from the compiler that the type will not change (it throws an error), plus a _promise_ that I will not change the value, or that I’m ok to pay the price of some subtle errors if I try to do it (since I can).

I cannot say any of you are entirely right. [`const` makes the binding constant.](https://docs.julialang.org/en/v1/base/base/#const)

This means: if you do not want to incur in undefined behaviour, you should never ever do `x = anything` if `x` is a `const` variable. The _consequences_ of this are that: it will never change type, as you cannot change _which_ object is associated with `x`; the compiler may just inline the object inside of `function` that reference it, and so if you change it the function will continue displaying the old value; immutable objects with no mutable fields (basically all `isbits` objects) like most numbers cannot be changed in any way; if `x` is a a `mutable struct` like `Vector` then you can change its contents and size because `const` is not about the contents of the object but about the binding, that is, it will forever be the _same_ object (i.e., all other scopes/functions that reference it can be sure the “memory address we are speaking of” will never change). For these coming from C, the behavior for `mutable structs` is similar to a `const` pointer to an object, and for the immutable objects is like a `const` variable holding the object itself (without the pointer indirection).

---

_[View the full topic](https://discourse.julialang.org/t/redefining-structs-without-restart/50826)._
