From jmc at research.bell-labs.com  Wed Oct 15 22:29:22 2003
From: jmc at research.bell-labs.com (John Chambers)
Date: Wed Oct 15 22:28:42 2003
Subject: [Rd] Infinite recursion in getGeneric (PR#4561)
References: <200310131616.h9DGGM0P018070@pubhealth.ku.dk>
	<3F8B086A.7D86C08D@research.bell-labs.com>
Message-ID: <3F8DAE22.95B39FC2@research.bell-labs.com>

John Chambers wrote:
> 
> saikat@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@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


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