Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run cell with variable-setting macro twice #371

Closed
cadojo opened this issue Sep 6, 2020 · 2 comments
Closed

Unable to run cell with variable-setting macro twice #371

cadojo opened this issue Sep 6, 2020 · 2 comments

Comments

@cadojo
Copy link

cadojo commented Sep 6, 2020

Some packages (MATLAB, ModelingToolkit) use macros for setting variables.

  • MATAB uses @mget x to copy a Matlab workspace variable x into a Julia variable called x.

  • ModelingToolkit uses @variables x y z to initialize symbolic variables x, y, and z.

In Pluto v0.11.12 (and all other versions I've used), you can't run any cell with either of these macros more than once.

Take ModelingToolkit's @variables as an example. If a cell contains:

@variables x

It will run correctly once. If the cell is run again, it produces the following error:

cannot assign a value to variable workspace24.x from module workspace25

The current workaround is to set x to nothing before calling @variables x in the same cell. It seems that a new module is created every time a cell is run. We probably only care about the latest module, right? Would it be possible to "forget" about modules 1 through 24 in this example?

@fonsp
Copy link
Owner

fonsp commented Sep 6, 2020

Thanks! Have a look at #196

@fonsp fonsp closed this as completed Sep 6, 2020
@fonsp fonsp mentioned this issue Sep 6, 2020
@fonsp
Copy link
Owner

fonsp commented Sep 6, 2020

You're right that forgetting about all unrecognized variables from previous workspace modules would fix the problem that you can't assign twice, but it will introduce a new problem: the variable only exists for one reactive run, and is forgotten afterward. This makes the macro even less useful 😥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants