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

View tree of expression stored in variable #21

Open
dpo opened this issue Feb 20, 2019 · 6 comments
Open

View tree of expression stored in variable #21

dpo opened this issue Feb 20, 2019 · 6 comments

Comments

@dpo
Copy link

dpo commented Feb 20, 2019

I'm on Julia 1.0.3, TreeView 0.3.1 in an IJulia notebook:

julia> myexpr = :(1.0 * x[1] + -1.0 * x[2] + -1.0 * x[3])
julia> @tree @eval myexpr
LabelledTree({4, 3} directed simple Int64 graph, Any[:macrocall, Symbol("@eval"), :(#= In[21]:1 =#), :objexpr])

On a side note, it took me a moment to realize that I needed @eval here. If this usage is correct, perhaps there could be an example in the README. This may also be related to #19?!

@dpo
Copy link
Author

dpo commented Feb 20, 2019

Sorry; brew install pdf2svg.

@dpo dpo closed this as completed Feb 20, 2019
@dpsanders
Copy link
Collaborator

Please feel free to suggest improvements for the README.

@dpo
Copy link
Author

dpo commented Feb 20, 2019

I got confused. The @eval trick doesn't work; it displays something else. How does one display an expression stored in a variable? Just call tree_walk(myexpr)?

@dpsanders dpsanders changed the title Tree doesn't show View tree of expression stored in variable Feb 20, 2019
@dpsanders dpsanders reopened this Feb 20, 2019
@dpsanders
Copy link
Collaborator

This is currently not enabled via the macro, though it would be a useful addition, so I've reopened the issue and changed the title.

Indeed just calling the function is a good workaround.

@dpo
Copy link
Author

dpo commented Feb 20, 2019

Ok, thank you!

@dpsanders
Copy link
Collaborator

The syntax could be @tree $myexpr. This requires explicitly handling the relevant $ syntax in the expression parser and escaping the resulting variable.

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