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

Parameters.jl dynamically created macros confuse Pluto #838

Closed
klaff opened this issue Jan 11, 2021 · 2 comments
Closed

Parameters.jl dynamically created macros confuse Pluto #838

klaff opened this issue Jan 11, 2021 · 2 comments

Comments

@klaff
Copy link

klaff commented Jan 11, 2021

Given the following example:

### A Pluto.jl notebook ###
# v0.12.18

using Markdown
using InteractiveUtils

# ╔═╡ bae82490-5443-11eb-33db-21137c0c6206
begin
	import Pkg
	Pkg.activate(mktempdir())
	Pkg.add("Parameters"); using Parameters
end

# ╔═╡ fb8743a0-5443-11eb-0606-f36d8925eacc
function f(p)
	@unpack_MyParams p
	a
end

# ╔═╡ daf1bdf0-5443-11eb-108a-3fa87ce15727
@with_kw mutable struct MyParams
	a::Int = 1
end

# ╔═╡ ef3aeb10-5443-11eb-189c-154c0b7693bd
p = MyParams()

# ╔═╡ 17fc92b0-5444-11eb-360e-0b7eaade4abf
f(p)

# ╔═╡ Cell order:
# ╠═fb8743a0-5443-11eb-0606-f36d8925eacc
# ╠═daf1bdf0-5443-11eb-108a-3fa87ce15727
# ╠═ef3aeb10-5443-11eb-189c-154c0b7693bd
# ╠═17fc92b0-5444-11eb-360e-0b7eaade4abf
# ╠═bae82490-5443-11eb-33db-21137c0c6206

When the file is first loaded, the function f(p) cell will fail with LoadError: UndefVarError: @unpack_MyParams not defined because the @unpack_MyParams macro won't be created until the @with_kw macro runs. The workaround is to manually rerun the function f(p) cell.

[EDIT] A better workaround is to add a MyParams line in any cell using @unpack_MyParams which gives Pluto enough info to get the order right.

# ╔═╡ fb8743a0-5443-11eb-0606-f36d8925eacc
function f(p)
	MyParams # makes cell dependency explicit for Pluto
	@unpack_MyParams p
	a
end
@fonsp
Copy link
Owner

fonsp commented Jan 12, 2021

This can only be solved by fully supporting macros. For that, see #196

@fonsp fonsp closed this as completed Jan 12, 2021
@klaff
Copy link
Author

klaff commented Jan 12, 2021

Yes, I just wanted to get this macro in the list.

pankgeorg pushed a commit that referenced this issue Jan 28, 2021
[Diff since v0.12.18](v0.12.18...v0.12.19)

**Closed issues:**
- GPU usage and console messages (#685)
- Feature Proposal: Exported HTML can be passed to a static site generator (#794)
- wait and resume execution on button press (#803)
- Latex code not appropriately displayed (#817)
- Python doesn't work in Pluto (#818)
- add pluto - pluto not found - Julia 1.5.3 macOS (#819)
- Cell output not shown correctly if in-line comment ends with semicolon (#820)
- _llvm (#821)
- Can't move cells (#822)
- Conditions on list comprehensions and execution order (#824)
- Electron app (#825)
- Errors when pressing Ctrl+C to stop Pluto (#827)
- Failed to load notebook error (#829)
- Popup docs don't work for some symbols (#832)
- Running a notebook deleted contents of `.julia/registries` (#834)
- Ctrl+C broken with `julia -e "Pluto.run()"` instead of the REPL (#836)
- Edit or remove default header and footer in exported static PDF (#837)
- Parameters.jl dynamically created macros confuse Pluto (#838)
- Feature request: Open URL from terminal (#840)
- Notebook gets stuck in forever loading state after restarting my PC while running it (#849)
- Syntax highlighting of @. (#854)
- File not found when file newly created while session is running (#855)
- Weird output from a mix of MathJax, Markdown and PlutoUI (#856)
- Misaligned plots when plotting with UnicodePlots.jl using BrailleCanvas (#870)

**Merged pull requests:**
- Pluto ux process file drop (#707) (@pankgeorg)
- Dralbase state managment (#710) (@dralletje)
- PLJ-785 CodeMirror Eject to TextArea - Reload from TextArea in Offline HTML export (#805) (@pankgeorg)
-  Dralbase state managment: Fix front-end tests (#809) (@pankgeorg)
- Update README.md (#814) (@fonsp)
- Regard `:=` in macros as einsum notation (take 2) (#816) (@mcabbott)
- 🧸 Open your own files as samples (#828) (@fonsp)
- Handle filters in generators, closes #824 (#839) (@Pangoraw)
- Update `== nothing` to `=== nothing` in Parse.jl (#841) (@heetbeet)
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