From jmc at research.bell-labs.com  Mon Oct 13 22:17:46 2003
From: jmc at research.bell-labs.com (John Chambers)
Date: Mon Oct 13 22:17:25 2003
Subject: [Rd] Infinite recursion in getGeneric (PR#4561)
References: <200310131616.h9DGGM0P018070@pubhealth.ku.dk>
Message-ID: <3F8B086A.7D86C08D@research.bell-labs.com>

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.

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.

As a heuristic, setting methods for language-related primitives is
dangerous (also a little strange?).

John

>  >
> 
> --please do not edit the information below--
> 
> Version:
>   platform = i686-pc-linux-gnu
>   arch = i686
>   os = linux-gnu
>   system = i686, linux-gnu
>   status =
>   major = 1
>   minor = 8.0
>   year = 2003
>   month = 10
>   day = 08
>   language = R
> 
> Search Path:
>   .GlobalEnv, package:methods, package:ctest, package:mva,
> package:modreg, package:nls, package:ts, Autoloads, package:base
> 
> ______________________________________________
> R-devel@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-devel

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