@enum persistence in Pluto.jl

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:

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!

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

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

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

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.

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?

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!

3 Likes

Pluto has some tricks to allow it anyways :slight_smile:

2 Likes

Thank you!

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

2 Likes

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

1 Like