[Rd] printing of attributes does not dispatch on class (PR#2506)

ripley@stats.ox.ac.uk ripley@stats.ox.ac.uk
Thu Jan 30 10:54:02 2003

Forwarded to R-bugs to log this.  It may or may not be a bug, but it is a 
desirable enhancement, if a tricky one.

Note that this is not simple: in R-devel it may be show() not print()  
that was called (and needs to be dispatched on, although print.default
will do that) and the print functionality can be called directly from C
code, e.g. by PrintValue.

Also, auto-printing as in the example does not call print.default at all
(put a trace on it to see). but the C function PrintValueEnv()!

Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

---------- Forwarded message ----------
Date: Thu, 30 Jan 2003 16:15:14 +1100
From: Mark.Bravington@csiro.au
To: r-devel@stat.math.ethz.ch
Subject: [Rd] print.default and attributes

When something gets printed by the "print.default" function, any extra
attributes are printed without regard to their class attribute (if any). For

> x <- 1:3
> attr( x, 'other') <- factor( c( 'cat', 'dog'))
> attr( x, 'other')
[1] cat dog
Levels: cat dog
> x
[1] 1 2 3
[1] 1 2

which is perhaps surprising. Would it be preferable for "print.default" to
call the generic "print" for each attribute, so that any class-specific
print methods are respected?