Skip to content

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

@wibeasley

Description

@wibeasley

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: r-lib/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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions