Skip to content

View tree of expression stored in variable #21

Open

Description

@dpo

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?!

Activity

  1. dpo commented on Feb 20, 2019

    @dpo
    Author

    Sorry; brew install pdf2svg.

  2. dpsanders commented on Feb 20, 2019

    @dpsanders
    Collaborator

    Please feel free to suggest improvements for the README.

  3. dpo commented on Feb 20, 2019

    @dpo
    Author

    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)?

  4. changed the title [-]Tree doesn't show[/-] [+]View tree of expression stored in variable[/+] on Feb 20, 2019
  5. dpsanders commented on Feb 20, 2019

    @dpsanders
    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.

  6. dpo commented on Feb 20, 2019

    @dpo
    Author

    Ok, thank you!

  7. dpsanders commented on Feb 20, 2019

    @dpsanders
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions