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

setup_reprex() #245

Closed
moodymudskipper opened this issue Nov 16, 2023 · 3 comments
Closed

setup_reprex() #245

moodymudskipper opened this issue Nov 16, 2023 · 3 comments

Comments

@moodymudskipper
Copy link
Collaborator

setup_reprex(fun, n = 1, nse = NULL)

  • fun : a function
  • n : number of reprexes to produce
  • nse: vector of args not to construct,

This basically traces the function for n calls, it opens a new untitled script every time, and constructs arguments and the call.

This is not the most general way to approach things because NSE and environments are complex, but this should really be ok for 99% use cases I think.

Call without a fun or n arg from inside the function itself to create a reprex while debugging, using locally modified values if relevant

@moodymudskipper
Copy link
Collaborator Author

We have a naming issue because we have 3 candidate reprex related features :

That's why I named this setup_reprex but it's not a great name either

Maybe:

  • construct_on_error()
  • construct_to_reprex()
  • construct_context()

@moodymudskipper
Copy link
Collaborator Author

The general way to deal with this is tricky, we should capture every argument's expression and environment (the env should be parent.frame() except for dots, we might use enquo() there), then check if the symbols used are accessible from that env, reconstruct these environments (at least the required objects, but even that is not completely general), then we we should use some quosures and inject() to be able to run the correct call, with BOTH same expressions and same values. This isa headache, I think we can have a "naive" mode and an "advanced" mode, and add an arg for this later, and just code the default "naive" approach for now, and if we're lucky we'll never really need the advanced one.

The draft PR #100 was trying some clever approaches but it's a can of worms.

@moodymudskipper
Copy link
Collaborator Author

Let's close for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant