# @enum persistence in Pluto.jl

**URL:** <https://discourse.julialang.org/t/enum-persistence-in-pluto-jl/43703>\
**Category:** General Usage\
**Tags:** pluto, enum\
**Created:** [July 26, 2020, 10:22am UTC](https://discourse.julialang.org/t/enum-persistence-in-pluto-jl/43703 "2020-07-26T10:22:33Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![perseid28](https://avatars.discourse-cdn.com/v4/letter/p/3ab097/32.png) [@perseid28](https://discourse.julialang.org/u/perseid28)\
**Post date:** [July 26, 2020, 10:22am UTC](https://discourse.julialang.org/t/enum-persistence-in-pluto-jl/43703/1 "2020-07-26T10:22:33Z")

</div>

When using a Pluto notebook, I realised that I cannot modify an `@enum` that I have created, either in the same or other cell. For example, executing a cell with:

`@enum myRainbow R=1 O Y G B I V`

followed by executing this or a different cell with the `@enum` modified at all:

`@enum myRainbow R=3 O Y G B I V`

gives an error:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/9/f/9f0ac0580ddb0fb14436292451096153d00b3429.png)

Is this because `@enum` types are created with a macro and not tracked in the same way as other objects? And is there a method that I can use if I want to reassign an `@enum` type (or even to delete it if I don’t need it…I really like Pluto’s philosophy of removing any variables that aren’t actively in a cell).

Thanks!

---

<div class="post-metadata">

**Author:** ![marcus](https://avatars.discourse-cdn.com/v4/letter/m/85e7bf/32.png) [@marcus](https://discourse.julialang.org/u/marcus)\
**Post date:** [July 26, 2020, 10:39am UTC](https://discourse.julialang.org/t/enum-persistence-in-pluto-jl/43703/2 "2020-07-26T10:39:03Z")

</div>

I think types in general cannot be modified in a Julia session after they have been defined.

---

<div class="post-metadata">

**Author:** ![perseid28](https://avatars.discourse-cdn.com/v4/letter/p/3ab097/32.png) [@perseid28](https://discourse.julialang.org/u/perseid28)\
**Post date:** [July 26, 2020, 10:53am UTC](https://discourse.julialang.org/t/enum-persistence-in-pluto-jl/43703/3 "2020-07-26T10:53:21Z")

</div>

But in my Pluto notebook I can, for example, define an array:

`A = [1,2,3,4]`

But when I delete this cell, trying to reference `A` again gives an error because Pluto has deleted the variable:

![image](https://global.discourse-cdn.com/julialang/original/3X/c/f/cf8380482ca868f2812a3ad834464fec8d538c98.png)

However, even after I have deleted the cell defining my `@enum`, I can continue to reference it:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/2/e/2e4f94a8db37b502bd8b326f57489db534e5fc66.png)

To try to express my question better: Pluto actually deletes variables(?) that are no longer defined, except for the `@enum` type which not only persists but does not allow subsequent modifications. This is not the same behaviour as the REPL which does allow me to modify an `@enum`, albeit with warnings that the keys have been modified.

---

<div class="post-metadata">

**Author:** ![marcus](https://avatars.discourse-cdn.com/v4/letter/m/85e7bf/32.png) [@marcus](https://discourse.julialang.org/u/marcus)\
**Post date:** [July 26, 2020, 11:00am UTC](https://discourse.julialang.org/t/enum-persistence-in-pluto-jl/43703/4 "2020-07-26T11:00:50Z")

</div>

You can relabel an `@enum` in the REPL but you can’t actually redefine it. For example, you can’t add additional colours to your `myRainbow` type. Have you tried redefining non-`@enum` type definitions in Pluto?

---

<div class="post-metadata">

**Author:** ![fonsp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fonsp/32/222349_2.png) [@fonsp](https://discourse.julialang.org/u/fonsp)\
**Post date:** [July 26, 2020, 1:31pm UTC](https://discourse.julialang.org/t/enum-persistence-in-pluto-jl/43703/5 "2020-07-26T13:31:35Z")

</div>

Hi! This is a bug in Pluto - it does not understand the macro `@enum`, so it does not know that this code _defines_ `myRainbow`, it looks like it _references_ `myRainbow`.

But I will add a special case for the `@enum` macro to fix it!

---

<div class="post-metadata">

**Author:** ![fonsp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fonsp/32/222349_2.png) [@fonsp](https://discourse.julialang.org/u/fonsp)\
**Post date:** [July 26, 2020, 1:33pm UTC](https://discourse.julialang.org/t/enum-persistence-in-pluto-jl/43703/6 "2020-07-26T13:33:03Z")

</div>

[https://github.com/fonsp/Pluto.jl/issues/233](https://github.com/fonsp/Pluto.jl/issues/233)

---

<div class="post-metadata">

**Author:** ![fonsp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fonsp/32/222349_2.png) [@fonsp](https://discourse.julialang.org/u/fonsp)\
**Post date:** [July 26, 2020, 1:35pm UTC](https://discourse.julialang.org/t/enum-persistence-in-pluto-jl/43703/7 "2020-07-26T13:35:21Z")

</div>

Pluto has some tricks to allow it anyways 🙂

---

<div class="post-metadata">

**Author:** ![perseid28](https://avatars.discourse-cdn.com/v4/letter/p/3ab097/32.png) [@perseid28](https://discourse.julialang.org/u/perseid28)\
**Post date:** [July 26, 2020, 2:18pm UTC](https://discourse.julialang.org/t/enum-persistence-in-pluto-jl/43703/8 "2020-07-26T14:18:24Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![fonsp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fonsp/32/222349_2.png) [@fonsp](https://discourse.julialang.org/u/fonsp)\
**Post date:** [July 27, 2020, 11:35am UTC](https://discourse.julialang.org/t/enum-persistence-in-pluto-jl/43703/9 "2020-07-27T11:35:26Z")

</div>

I have fixed the issue! It will be released in `v0.11.1` (sometime this week).

---

<div class="post-metadata">

**Author:** ![perseid28](https://avatars.discourse-cdn.com/v4/letter/p/3ab097/32.png) [@perseid28](https://discourse.julialang.org/u/perseid28)\
**Post date:** [July 29, 2020, 6:59pm UTC](https://discourse.julialang.org/t/enum-persistence-in-pluto-jl/43703/10 "2020-07-29T18:59:18Z")

</div>

I finally got a chance to try it out today. It sure is fixed, thanks again!!
