couldn't find function "print.tframe"

Peter Dalgaard BSA
17 May 1998 12:08:18 +0200

Thomas Lumley <> writes:

> Ok. The print.tframe problem appears to be as follows:
> When printList has a list element that is an object it creates a call to
> print() with the evaluated object and evaluates that call in the
> environment R_NilValue (ie NULL).
> If this object has class "foo" is called. If there is a 
> NextMethod() in, do_nextmethod  reaches back to find
> the environment that print() was called from and looks for the
> definition of that applies there, in order to get the formal
> arguments right.  This fails, since print() was 'called' from the NULL
> environment, where is not defined.
> You can reproduce this in interpreted code by
> R> b<-1              
> R> class(b)<-"foo" 
> R><-function(x){cat("foo\n");NextMethod()}
> R> eval(expression(print(structure(1,class="foo"))),NULL)


Here's another aspect of the problem:

I tried creating a new print function with a call to sys.status
inserted befor the UseMethod, after previously doing a debug(print),

>  eval(expression(print(structure(1,class="foo"))),NULL)
debugging in: print(structure(1, class = "foo"))
Error: couldn't find function ""

So it is still calling the old print (in package:base). The new one
would have debugging turned off for one thing. (BTW: Why doesn't the
debugger stop and wait for input before doing the UseMethod call?)

In contrast,
> b
print(structure(1, class = "foo"))

[1] 1
[1] "foo"

   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (             FAX: (+45) 35327907

r-devel mailing list -- Read
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: