[Rd] infinite recursion during package installation with methods, setAs

Roger D. Peng rpeng at jhsph.edu
Sun Sep 28 18:09:04 MEST 2003


I ran into a problem recently trying to update a package which uses S4 
methods using a recent beta of R.  I think I can reproduce it with a 
simple example.  I have package called `testpkg' in directory testpkg/.
In the R/ subdirectory of testpkg/ I have a file called testpkg.R which 
contains the following two lines:

setClass("testpkg", representation(pts = "list"))
setAs("testpkg", "numeric", function(from, to) as.numeric(unlist(from)))

Then, in the main testpkg/ directory I have an empty `install.R' file 
and a dummy DESCRIPTION file (as well as an empty man/ subdirectory).

When I run `R CMD INSTALL testpkg' I get the following output:

marla:> R CMD INSTALL testpkg
* Installing *source* package 'testpkg' ...
** R
** save image
[1] "testpkg"
Loading required package: testpkg
Loading required package: testpkg
Loading required package: testpkg
Loading required package: testpkg
Loading required package: testpkg
Loading required package: testpkg
Loading required package: testpkg
Loading required package: testpkg
Loading required package: testpkg
Loading required package: testpkg
Loading required package: testpkg
Error during wrapup: evaluation is nested too deeply: infinite recursion?
Loading required package: testpkg
Error in options(x) : evaluation is nested too deeply: infinite recursion?
Error: evaluation is nested too deeply: infinite recursion?
Error: evaluation is nested too deeply: infinite recursion?
Error: evaluation is nested too deeply: infinite recursion?
Error: evaluation is nested too deeply: infinite recursion?
Error: evaluation is nested too deeply: infinite recursion?
Error: evaluation is nested too deeply: infinite recursion?
Error: evaluation is nested too deeply: infinite recursion?
Error: evaluation is nested too deeply: infinite recursion?
Error: evaluation is nested too deeply: infinite recursion?
Error: evaluation is nested too deeply: infinite recursion?
Error: evaluation is nested too deeply: infinite recursion?
Error: evaluation is nested too deeply: infinite recursion?
Execution halted
ERROR: execution of package source for 'testpkg' failed
** Removing '/home/rpeng/install/R-beta/lib/R/library/testpkg'

Is this expected?  Did I specify something incorrectly?

If I remove the setAs() call, everything installs fine.  Furthermore, if 
I include a line like:

setAs("numeric", "testpkg", function(from, to) list())

that doesn't seem to cause a problem.  I only get the infinite recursion 
problem when the first argument to setAs() is the new class "testpkg".


 > version
          _
platform i686-pc-linux-gnu
arch     i686
os       linux-gnu
system   i686, linux-gnu
status   beta
major    1
minor    8.0
year     2003
month    09
day      27
language R


-roger



More information about the R-devel mailing list