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

Parent named list elements not kept as guides in lists #141

Closed
brodieG opened this issue Nov 8, 2019 · 3 comments
Closed

Parent named list elements not kept as guides in lists #141

brodieG opened this issue Nov 8, 2019 · 3 comments
Labels
Milestone

Comments

@brodieG
Copy link
Owner

brodieG commented Nov 8, 2019

library(diffobj)
lm1 <- lm2 <- lm(mpg ~ hp, mtcars)
attr(lm2$qr$qr, 'assign') <- c(1, 0)
diffPrint(unclass(lm1), unclass(lm2))

image

Should preserve one more $qr

@brodieG brodieG added this to the 0.3 milestone Feb 28, 2020
@brodieG brodieG added the bug label Mar 10, 2020
@brodieG
Copy link
Owner Author

brodieG commented May 10, 2020

This is because the list print method does not print the parent list element when the child is a classed list, presumably because it does not want to interfere with a potential print method of the child, but I think that's probably bad.

@brodieG
Copy link
Owner Author

brodieG commented May 10, 2020

Indeed, when recursively printing, the global tag buffer gets reset by the print.default method.

A possible solution would be to make the tag buffer reset the responsibility of printValueRec, where it would record on first call that print recursion is active and on exit reset the tag buffer.

There are two obvious issues with this:

  1. The code becomes more complex because in addition to the global recursion state variable, we also need to add a context so we can have an on.exit cleanup in case something along the print recursion triggers an error or similar. There already is a context that is ifdef'ed for win32, so we'd have to combine that handling. Not sure what the performance implications of that are.
  2. If the author of a print method for an S3/S4 object relies internally on the default print methods, they will expect the tag buffer to be reset for them. This means we need a way to recognize that print.default was called internally by the C print recursion code, vs by a the owner of an object print method.

@brodieG
Copy link
Owner Author

brodieG commented May 10, 2020

See #146 for a possible future work-around.

Also Lionel's issue on bugzilla, and discussion on r-devel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant