# Destructuring syntax does not respect const annotation

**URL:** <https://discourse.julialang.org/t/destructuring-syntax-does-not-respect-const-annotation/88751>\
**Category:** Internals & Design\
**Tags:** constants, destructuring\
**Created:** [October 14, 2022, 7:56pm UTC](https://discourse.julialang.org/t/destructuring-syntax-does-not-respect-const-annotation/88751 "2022-10-14T19:56:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![greatpet](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Post date:** [October 14, 2022, 7:56pm UTC](https://discourse.julialang.org/t/destructuring-syntax-does-not-respect-const-annotation/88751/1 "2022-10-14T19:56:03Z")

</div>

The `const` keyword seems to have no effect when used with the destructuring syntax in Julia 1.7+.

```julia
julia> t = (;a = 1, b = 2);

julia> const (;a, b) = t
(a = 1, b = 2)

julia> a = 3 # re-definition produces no error or warning, so a is not const
3

```

So I have to resort to the more lengthy code

```julia
const (a, b) = (t.a, t.b)

```

This was discussed before, but the workaround [in a previous post](https://discourse.julialang.org/t/how-to-desctructure-a-namedtuple-and-declare-the-variables-to-be-constants-using-the-new-destructuring-syntax/76830) doesn’t / no longer work with either Julia 1.8.0 or 1.7.3 on my computer.

Would it be desirable for Julia to implement the `const` annotation as used above? Or is there a language reason that it would be unsound?

---

<div class="post-metadata">

**Author:** ![Keno](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/keno/32/285_2.png) [@Keno](https://discourse.julialang.org/u/Keno)\
**Post date:** [October 14, 2022, 8:17pm UTC](https://discourse.julialang.org/t/destructuring-syntax-does-not-respect-const-annotation/88751/2 "2022-10-14T20:17:30Z")

</div>

That seems like a bug, please file this as a GitHub issue.

---

<div class="post-metadata">

**Author:** ![greatpet](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Post date:** [October 14, 2022, 8:55pm UTC](https://discourse.julialang.org/t/destructuring-syntax-does-not-respect-const-annotation/88751/3 "2022-10-14T20:55:32Z")

</div>

OK, done that.

> <https://github.com/JuliaLang/julia/issues/47168>
>
> The const keyword seems to have no effect when used with the destructuring synta…x in Julia 1.7+.
> 
> \`\`\`
> julia\> t = (;a = 1, b = 2);
> 
> julia\> const (;a, b) = t
> (a = 1, b = 2)
> 
> julia\> a = 3 # re-definition produces no error or warning, so a is not const
> 3
> \`\`\`
> My Julia version is 1.8.2, 64-bit Linux (glibc), installed from the binary tarball.
> (First posted on Discourse: \[https://discourse.julialang.org/t/destructuring-syntax-does-not-respect-const-annotation/88751\](https://discourse.julialang.org/t/destructuring-syntax-does-not-respect-const-annotation/88751))
