From ||one| @end|ng |rom r@tud|o@com  Wed May 22 16:25:46 2019
From: ||one| @end|ng |rom r@tud|o@com (Lionel Henry)
Date: Wed, 22 May 2019 10:25:46 -0400
Subject: [Rd] print.<strorageMode>() not called when autoprinting
In-Reply-To: <23780.65330.841197.95483@stat.math.ethz.ch>
References: <CAF8bMcatAtZ_LPWZk3QxVQXS5qHA14_j=_tBvGbbH+m0kBYnAQ@mail.gmail.com>
 <23780.10058.726995.538115@stat.math.ethz.ch>
 <CAF8bMcYeVioX6-vxz+-P6SsFHyoU6QSBD55_veNcvXpw7wEdyA@mail.gmail.com>
 <76885C3C-1100-490B-990E-5519F6AAD40B@rstudio.com>
 <CAF8bMcYX5o2joaqXa2F2Tw8iU-CvN8FmmGm58Yezs-RnwWxEGQ@mail.gmail.com>
 <23780.65330.841197.95483@stat.math.ethz.ch>
Message-ID: <411491BA-CE6C-4289-954B-EF3D31670669@rstudio.com>

Hi Martin,

> On 22 May 2019, at 03:50, Martin Maechler <maechler at 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

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



[Rd] print.<strorageMode>() not called when autoprinting
Lionel Henry