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

defer() on globalenv could mimic reg.finalizer? #133

Closed
daattali opened this issue Apr 28, 2020 · 2 comments
Closed

defer() on globalenv could mimic reg.finalizer? #133

daattali opened this issue Apr 28, 2020 · 2 comments

Comments

@daattali
Copy link

daattali commented Apr 28, 2020

I saw @jennybc 's post about testing with withr and it talked about how defer() in the globalenv is strange. When I thought of defer in globalenv, I immediately though it would just act like reg.finalizer(). Is this not a good idea?

@jennybc
Copy link
Member

jennybc commented Apr 28, 2020

@hadley actually wondered out loud in the PR whether we should use reg.finalizer() to make sure the deferred global events actually run #76 (review). If you scroll down, you can see the conversation. I actually don't feel like I want that behaviour.

I interpret the fact that this was merged without reg.finalizer() as weak affirmation that my view is OK. But maybe it's not completely settled?

@hadley
Copy link
Member

hadley commented Apr 29, 2020

I think both your argument and my argument have merits, but the advantage of guaranteeing clean up on exit are rather mild (since most of the time effects are session specific or in a session-specific temp directory anyway), that using reg.finalizer() would have few additional benefits.

@hadley hadley closed this as completed Apr 29, 2020
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

3 participants