couldn't find function "print.tframe"

Thomas Lumley Thomas Lumley <thomas@biostat.washington.edu>
Sat, 16 May 1998 12:39:40 -0700 (PDT)


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" print.foo() is called. If there is a 
NextMethod() in print.foo, do_nextmethod  reaches back to find
the environment that print() was called from and looks for the
definition of print.foo() that applies there, in order to get the formal
arguments right.  This fails, since print() was 'called' from the NULL
environment, where print.foo() is not defined.

You can reproduce this in interpreted code by
R> b<-1              
R> class(b)<-"foo" 
R> print.foo<-function(x){cat("foo\n");NextMethod()}
R> eval(expression(print(structure(1,class="foo"))),NULL)

The question is how to find the right environment to evaluate the call,
since printList doesn't know what environment print() was called from. 
R_GlobalEnv doesn't seem right, since print.foo may not be defined there. 

One solution would be to explicitly pass the environment down, but this
takes a lot of changes, some of them to functions called from outside
print.c.  I'm looking at this but would welcome a better solution.


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