[Rd] Infinite recursion in getGeneric (PR#4561)

John Chambers jmc at research.bell-labs.com
Wed Oct 15 22:29:22 MEST 2003


John Chambers wrote:
> 
> saikat at stat.wisc.edu wrote:
> >
> >  > setClass('foo')
> > [1] "foo"
> >  > setMethod('is.logical', 'foo', function(x) TRUE)
> > [1] "is.logical"
> >  > getGeneric('is.integer')
> > Error in options(x) : evaluation is nested too deeply: infinite
> > recursion?
> 
> This is one of a number of potential problems when methods are specified
> for  primitive functions used in the R code that dispatches methods.
> 
> There is a fix for this particular example -- I will commit it to
> r-patched.

Committed to r-patched.

> 
> However, the only real safety will come when primitives are not
> dispatched from a global structure (a change planned for 1.9).  Then the
> version of primitives used in method dispatch can be separated from any
> methods defined in a different namespace.
> 
> For example, a quick test showed that even after the above fix, setting
> methods for "is.null" causes similar problems.

A list of primitives has been set up that are known or suspected to
cause this sort of problem (is.null, is.primitive, is.function,
is.object).  Until the general fix is in place, an attempt to set
methods for these functions will cause an error.

If you encounter any other primitives that produce symptoms such as
above (an "evaluation nested" error after setting a method for the
function), please report them.

John

-- 
John M. Chambers                  jmc at bell-labs.com
Bell Labs, Lucent Technologies    office: (908)582-2681
700 Mountain Avenue, Room 2C-282  fax:    (908)582-3340
Murray Hill, NJ  07974            web: http://www.cs.bell-labs.com/~jmc



More information about the R-devel mailing list