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

Avoid early materialization of ALTREP objects #4210

Merged
merged 2 commits into from
Jan 23, 2019
Merged

Conversation

jmcphers
Copy link
Member

Currently, ALTREP objects (new in R 3.5.0) are fully materialized by RStudio's environment pane, since it calls object.size() on them. This change protects these objects from premature evaluation by avoiding the environment pane's size/length inspection on objects with the alt flag set (indicating an ALTREP).

Note that this does not protect the objects from any type of materialization at all; the first few elements will still be materialized by str(), which we continue to call.

Fixes #4171.

@kevinushey
Copy link
Contributor

LGTM!

Do we need any UI-side changes so that the Environment pane reports something reasonable for these objects (when in Grid view)?

public:
bool empty() const { return versionMajor_ != 0; }
bool empty() const { return versionMajor_ == 0; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Yikes! I guess we weren't ever really exercising this code path before?

Copy link
Member Author

Choose a reason for hiding this comment

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

We were not! As far as I can tell this method was never used before.

@jmcphers
Copy link
Member Author

Do we need any UI-side changes so that the Environment pane reports something reasonable for these objects (when in Grid view)?

We just report them as having no size -- the same thing we do for other "don't touch" objects (active bindings, uneval'ed promises, etc.)

@kevinushey
Copy link
Contributor

Gotcha. I think that's fine.

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

Successfully merging this pull request may close these issues.

None yet

2 participants