couldn't find function "print.tframe"

Thomas Lumley thomas@biostat.washington.edu
Sat, 16 May 1998 11:04:33 -0700 (PDT)


On Fri, 15 May 1998, Paul Gilbert wrote:

> I have an object with an attribute "tframe" for which there is a generic method
> print.tframe and also a method print.tframe.default defined in a library.
> However, when I use attributes(object) I get the message
> 
> $tframe
> Error: couldn't find function "print.tframe"
> 
> It's as if <primitive: attributes> is not looking through the search list?

It's more subtle than this.  If you  do
R> b<-1
R> class(b)<-"foo"
R> print.foo<-function(x) { print("foo\n"); NextMethod()}

Then printing b works perfectly well

R> b
foo
[1] 1
attr(,"class")
[1] "foo"

and the problem arises when you print a list containing b

R> list(b,1)
[[1]]
foo
Error: couldn't find function "print.foo"

The error happens in the NextMethod() call of print.foo(), at line 284 of
objects.c, where do_nextmethod tries to find the function that called it.

	/* set up the arglist */
	s=findFun(CAR(cptr->call), cptr->sysparent);

In the working case, cptr->sysparent is R_GlobalEnv, in the non-working
case it's R_NilValue (ie, NULL)

BTW, the gcc documentation says that if we used gcc -g3 in compiling,
some debuggers would be able to cope with macros like CAR() and TYPEOF().
Does anyone know if gcc is one of them?


Thomas Lumley
------------------------------------------------------+--------
Biostatistics		: "Never attribute to malloc(3) what  :
Uni of Washington	:  can be adequately explained by     :
Box 357232		:  incompetence"                      :
Seattle WA 98195-7232	:				      :
--------------------------------------------------------------


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._