R-alpha: generic print

Paul Gilbert la-jassine@aix.pacwan.net
Wed, 30 Apr 1997 07:25:53 -0300


I have  always thought that typing the name of an object generated a call to
the print method for the object, however,  (in 0.49) I redefined the generic
print method as 

print <- function(x, ...)
 {if (is.tframe(x))  UseMethod("print.tframe")
  else UseMethod("print")
 }

Now I have an object z which returns TRUE to is.tframe(z) and
> class(z)
[1] "ts"     "tframe"

Then

> print(z)
[1] 1981.50 2006.25    4.00

But
> z
Error: comparison is possible only for vector types

> traceback()
[1] "c(\"print.ts(structure(c(1981.5, 2006.25, 4), class = c(\\\"ts\\\",
\\\"tframe\\\"\", "
[2] "c(\"print(structure(c(1981.5, 2006.25, 4), class = c(\\\"ts\\\",
\\\"tframe\\\"\", "   

This is generating a call to the class method print.ts rather than to
print.tframe.ts as is done when I use print(z).  If my understanding that
typing the name of an object should generate a call to the print method for
the object then this is a bug. Otherwise, could someone please explain to me
what it does. Thanks.

Paul Gilbert

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
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
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-