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

kwagrs for macro calls #252

Closed
mcmcgrath13 opened this issue Aug 4, 2020 · 6 comments
Closed

kwagrs for macro calls #252

mcmcgrath13 opened this issue Aug 4, 2020 · 6 comments
Assignees
Labels
expression explorer Figuring out assignments and references in a cell other packages Integration with other Julia packages

Comments

@mcmcgrath13
Copy link

I started working on supporting rendering of the vega and vegalite mime types (nominally working!), but I ran into the below issue when trying to have two plots:

image

I ran @macroexpand on the expressions and got:

:(dataset("cars") |> (VegaLite.VegaLite).VLSpec(VegaLite.convert_frag_tree_to_dict(VegaLite.fix_shortcut_level_spec((VegaLite.VLFrag)(VegaLite.Any[:point], VegaLite.OrderedDict{VegaLite.String, VegaLite.Any}("x" => :Horsepower, "y" => :Miles_per_Gallon))))))

I'm not sure why it's registering the x and y as variables in the main scope. Any idea what's happening here?

@fonsp fonsp changed the title Vega / VegaLite support kwagrs for macro calls Aug 4, 2020
@fonsp fonsp added the expression explorer Figuring out assignments and references in a cell label Aug 4, 2020
@fonsp fonsp self-assigned this Aug 4, 2020
@fonsp
Copy link
Owner

fonsp commented Aug 4, 2020

Thanks!

Pluto works by figuring out the set of assigned variables and referenced variables for each cell. If one cell references a symbol x, and and another assigns to x, then that is a reactive link between them.

In this case, a bug in the analysis treats the keyword argument x=:asdf as an assignment. I wrote a special case for function calls, but not for macros.

A more general problem is that Pluto doesn't understand macros (#196), but luckily this macro can be parsed as if it is a function call - it does not need to be expanded for the syntax analysis to work.

@fonsp fonsp added the other packages Integration with other Julia packages label Aug 16, 2020
@fonsp fonsp closed this as completed Aug 19, 2020
@fonsp
Copy link
Owner

fonsp commented Aug 19, 2020

Should be fixed now, can you try again?>

@fonsp
Copy link
Owner

fonsp commented Aug 19, 2020

You need to run the master branch of Pluto

@mcmcgrath13
Copy link
Author

I'm using the master branch of Pluto, but still seeing the same issue:

image

@fonsp fonsp reopened this Aug 24, 2020
@fonsp
Copy link
Owner

fonsp commented Aug 25, 2020

This can't be fixed without expanding the macro (#196):
@f(x=y)
and
@f x = y
produce the same Expr, and something that looks like the second expression should be recognised as an assignment to x. (@benchmark x = y for example)

Try using a semicolon:

@vlplot(
	:a;
	x = :b,
	...
)

@fonsp fonsp closed this as completed Aug 25, 2020
@fonsp
Copy link
Owner

fonsp commented Nov 19, 2020

This has been fixed by #670

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
expression explorer Figuring out assignments and references in a cell other packages Integration with other Julia packages
Projects
None yet
Development

No branches or pull requests

2 participants