flow
flow copied to clipboard
Improve flow_view_vars()
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 -> var1andfor -> var2with greenvar1andvar2, alsofor -> 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_boxandvar2 -> 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.