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

Provide introspection for the dynamic state of the pipe #175

Open
lionel- opened this issue Aug 31, 2018 · 0 comments
Open

Provide introspection for the dynamic state of the pipe #175

lionel- opened this issue Aug 31, 2018 · 0 comments
Labels
feature a feature request or enhancement

Comments

@lionel-
Copy link
Member

lionel- commented Aug 31, 2018

So when an error occurs, we can unroll the pipe properly in the backtrace. I'm going to hardcode logic based on 1.5 internals in rlang for the time being so we should coordinate before the next release of magrittr.

For illustration, let's say that T() below throws and a backtrace is recorded:

F(NA) %>% F() %>% T() %>% F() %>% F()

We want to unroll the pipe but not the last two steps as they were not evaluated yet:

Full:
█
└─F(NA) %>% F() %>% T() %>% F() %>% F()
  ├─withVisible(eval(quote(`_fseq`(`_lhs`)), env, env))
  └─eval(quote(`_fseq`(`_lhs`)), env, env)
    └─eval(quote(`_fseq`(`_lhs`)), env, env)
      └─`_fseq`(`_lhs`)
        └─freduce(value, `_function_list`)
          └─function_list[[i]](value)
            └─T(.)

Collapsed:
█
└─[ F(NA) %>% F() %>% T() %>% F() %>% F() ] ... +6
  └─T(.)

Trail:
 ─F(NA)
 ─F(.)
 ─T(.)

Useful pieces of information:

  • How many pipe calls have already been evaluated
  • Frame index of the evaluation loop so that it's easy to collapse irrelevant sections of the call tree.
  • Caller environment

Probably best to record it in the very first frame, the one whose call is x %>% y %>% z.

@hadley hadley added the feature a feature request or enhancement label Apr 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants