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

following arguments around #168

Open
moodymudskipper opened this issue Dec 6, 2023 · 0 comments
Open

following arguments around #168

moodymudskipper opened this issue Dec 6, 2023 · 0 comments

Comments

@moodymudskipper
Copy link
Owner

Use case:

  • I provide a parameter arg1 to a function
  • This parameter is used to build some more variables, that in turn are passed to other functions
  • Some other variables are defined from those, and passed around and so on
  • Question: show me the tree of all functions affected by this argument

No strong opinion yet on the api but it seems to me the result is just a subset of flow_view_deps, so maybe in practice that's just an arg = NULL argument to flow_view_deps() ?

The easier way to do it is just detect assignments that have the arg on the rhs and collect the lhs recursively (considering assignment functions foo<- as well). then we keep deps on the intersection on callers (consider that with things like x <- foo(y, bar(arg)) both foo and bar must be considered).

The harder way is to acknowledge that we might have placeholder/temp variables used for different purposes, so we have to implement something like flow_view_vars()'s technology to be more accurate.

We could also have a run() variant, I think with bagtools::chatty() I had a trick to track an object, and maybe objects that used it, using active bindings that assessed their environment and call anytime they were accessed.

We can have something like :

my_function(x, follow_me(y))

where follow_me() (flow_me() ?) can make y one such sneaky active binding, and we trace sys.fun(1) so it prints the flow diagram on exit. I think using follow_me() several times there comes basically for free.

We might not be able to guess the calling function when not called from the top level, so maybe we can have follow_me(arg, fun = sys.function(1)) for flexibility, and a bit of free transparency on the magic.

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

1 participant