saikat@stat.wisc.edu
2003-Oct-13 18:15 UTC
[Rd] Infinite recursion in getGeneric (PR#4561)
> 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? > --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
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
On Monday, Oct 13, 2003, at 16:17 US/Eastern, John Chambers wrote:> As a heuristic, setting methods for language-related primitives is > dangerous (also a little strange?).Yes. But if it is allowed, someone will do it. It may actually make sense to come up with an appropriate (and preferably small) list of primitive functions and say that you can not define methods for them (at least easily).