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

on.exit() checks for add parameter to be explicitly set. #138

Open
wibeasley opened this issue Feb 1, 2020 · 0 comments
Open

on.exit() checks for add parameter to be explicitly set. #138

wibeasley opened this issue Feb 1, 2020 · 0 comments

Comments

@wibeasley
Copy link

Consider adding a check that when on.exit() is called, that the add = TRUE argument is passed.

Alternative: if TRUE is too restrictive, maybe require that add = FALSE be explicitly mentioned. This should make it a little more clear to that the previous calls to on.exit() will be clobbered.

(If you give me a few pointers, I'm happy to try adding this. Right now, I don't have a good understanding how this would be checked follow this package's approach.)

Sources:

  1. https://adv-r.hadley.nz/functions.html#on-exit

    Always set add = TRUE when using on.exit(). If you don’t, each call to on.exit() will overwrite the previous exit handler. Even when only registering a single handler, it’s good practice to set add = TRUE so that you won’t get any unpleasant surprises if you later add more exit handlers.

  2. from yihui: vubiostat/r-yaml@67496b6

    on.exit(add = TRUE) is almost always the right thing to do

    Without add = TRUE, it is easy to shoot yourself in the foot when you have other on.exit() calls.

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

No branches or pull requests

2 participants