Skip to content

Move build-time calculations to .onLoad() #3275

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

Merged
merged 1 commit into from
Apr 29, 2019

Conversation

thomasp85
Copy link
Member

Fixes #3233

Two instances were observed and moved too .onLoad() after going through the full source code

@thomasp85 thomasp85 added this to the ggplot2 3.2.0 milestone Apr 26, 2019
@thomasp85 thomasp85 requested a review from clauswilke April 26, 2019 19:53
@@ -19,6 +19,10 @@
.onLoad <- function(...) {
backport_unit_methods()

.zeroGrob <<- grob(cl = "zeroGrob", name = "NULL")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand the documentation to .onLoad() correctly (https://stat.ethz.ch/R-manual/R-devel/library/base/html/ns-hooks.html), this should be grid::grob.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think so - where do you see that? .onLoad() is called after the namespace is loaded

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was commenting based on the following sentence. It's possible I misinterpreted it.

Note that the code in .onLoad and .onUnload should not assume any package except the base package is on the search path. Objects in the current package will be visible (unless this is circumvented), but objects from other packages should be imported or the double colon operator should be used.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a throwback to ancient times when packages could assume default packages were loaded (e.g. stats) and thus didn't need to be imported in the namespace file... grid is imported by ggplot2 so it's all good

@thomasp85 thomasp85 merged commit 552707f into tidyverse:master Apr 29, 2019
@lock
Copy link

lock bot commented Oct 26, 2019

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Oct 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove build time code execution
2 participants