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

[BUGZILLA #16963] In ?on.exit, add note that on.exit expressions are evaluated after return() call. #6269

Open
MichaelChirico opened this issue May 19, 2020 · 0 comments

Comments

@MichaelChirico
Copy link
Owner

I suggest adding a note at the end of the Details section of help(on.exit) indicating:

Expressions are evaluated after the function's return value is evaluated, so on.exit cannot be used to modify the return value.

Here is an example (which you could add to the Examples section, but I don't think it is worth it):

f <- function() {
result <- list(a = 1)
on.exit(result$b <- 2)
return(result)
}
f()
# only includes $a, not $b.


METADATA

  • Bug author - Tim Hesterberg
  • Creation time - 2016-06-22 17:29:19 UTC
  • Bugzilla link
  • Status - UNCONFIRMED
  • Alias - None
  • Component - Documentation
  • Version - R 3.2.4
  • Hardware - All All
  • Importance - P5 enhancement
  • Assignee - R-core
  • URL -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant