On Wed, 22 May 2019, Lionel Henry wrote: > Hi Martin, > >> On 22 May 2019, at 03:50, Martin Maechler <maech...@stat.math.ethz.ch> wrote: >> >> I'm pretty sure that all teaching and documentation about S and R >> has suggested that print(f) and auto-printing should result in >> the same output _ AFAIR also for S4 objects
Looks like we intend auto-printing to do what evaluating the expression if (base::isS4(base::.Last.value)) methods::show(base::.Last.value) else base::print(base::.lastValue) would do. The simplest approach would be to save this expression and pass it to eval, or define an equivalent .autoprint function. That would avoid code duplication and divergence. I'm guessing the main reason we don't do this is that going through the print() closure bumps NAMED on the value and forces a duplicate on a subsequent assignment. This issue would disappear if we could manage the transition to reference counting. In the meantime it would seem best to keep any changes consistent with evaluating this expression. Best, luke > > I agree with the principle that autoprint and print() should be > equivalent for users. However it also seems that print calls in > packages should be independent of user customisations. For instance a > package author might gather tabular data in a matrix or data frame and > print() it as part of a larger print method. In that case, user > customisations might cause a mess. > > Would it make sense to resort to autoprint customisation when the > topenv() of the parent.frame() of print() is the global environment, > and ignore the customisation otherwise? This should ensure consistent > printing behaviour at the REPL and in scripts. Checking the topenv() > allows print() calls inserted to debug lapply'd functions to behave the > same as when called from top level or within a loop. > > Lionel > > ______________________________________________ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > -- Luke Tierney Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics and Fax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel