[Rd] Guidelines for print methods?

Duncan Murdoch murdoch@stats.uwo.ca
Tue, 23 Jan 2001 10:55:59 -0500


Are there guidelines for what print methods should do?  The reason I
ask is that I was recently confused by what Sys.time prints:

> Sys.time()
[1] "2001-01-23 10:38:17"

I thought from the look of this that Sys.time returned a string, not
an object with a class.  (The help is clear that it returns an object,
but I didn't get that far.) The problem is that print.POSIXct() calls
print() to print the result, rather than cat(), like many other print
methods.

I prefer the printing using cat(), because then it's clear that
there's a print method involved, it's not print.default just
displaying a vector.

Of course, I could have a vector of multiple POSIXct values, in which
case calling print() would probably be appropriate.  (But it might
still be a good idea to use "quote=FALSE" to let me know there's
something special there.)

Shouldn't a print method give some indication that what is being
printed isn't a simple vector?  I'm interested in others' opinions on
this.

Duncan Murdoch
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._