flow icon indicating copy to clipboard operation
flow copied to clipboard

Improve flow_view_vars()

Open moodymudskipper opened this issue 2 years ago • 0 comments

several things, by order of difficulty


(1)

Side effects called are not shown so we might feel like there is dead code when there is not.

For instance:

env <- new.env()
foo <- 1
assign("bar", foo, envir = env)

we could have env -> assign() and foo -> assign() in the diagram, because assign() is at the top level (not a call to <-).

These side effect calls would be leaves by definition (don't create a local variable, explicitly at least), they probably should have a bright color, maybe orange.


(2) We might provide a list of NSE functions, this means providing a function and the arguments to ignore. Now we special case "quote", "~", "function", "$".


(3) We might display full calls, or calls of the form foo <- bar(...) using ... when they're too long (we need single line and say <60 char, adjustable), so reading the diagram is much more like reading the actual code.


(4)

We probably won't ever get there but I wonder if flow_view() and flow_view_vars() can be unified.

  • control flows would be represented as functions of the existing variables they use, so we'd have for -> var1 and for -> var2 with green var1 and var2, also for -> i (or relevant variable). and then have a regular flow_view_vars style diagram in a box around it.

  • To the for box we'd have var1 -> for_box and var2 -> for_box

  • From the for box we'd repeat the the variables used by ulterior code, like for_box -> var1, for_box -> new_var, in default color.

Then we'd have the perfect logical flow, albeit probably very busy.

moodymudskipper avatar May 05 '23 10:05 moodymudskipper