Re: [Rd] reducing redundant work in methods package

2015-01-22 Thread Michael Lawrence
Actually, after reading the comment about it being OK for it being NULL, it's not a bug after all. On Thu, Jan 22, 2015 at 5:57 AM, Michael Lawrence wrote: > I also just noticed that there is a bug: identical(ans, FALSE) should > be is.null(ans). > > So no error is thrown: >> methods:::genericFor

Re: [Rd] reducing redundant work in methods package

2015-01-22 Thread Michael Lawrence
I also just noticed that there is a bug: identical(ans, FALSE) should be is.null(ans). So no error is thrown: > methods:::genericForPrimitive("foo") NULL Will fix. On Wed, Jan 21, 2015 at 3:13 PM, Peter Haverty wrote: > Doing it like this: > > genericForPrimitive <- function(f, where = topenv(p

Re: [Rd] reducing redundant work in methods package

2015-01-21 Thread Peter Haverty
Doing it like this: genericForPrimitive <- function(f, where = topenv(parent.frame()), mustFind = TRUE) { ans = .BasicFunsList[[f]] ## this element may not exist (yet, during loading), dom't test null if(mustFind && identical(ans, FALSE)) stop(gettextf("methods may not be d

Re: [Rd] reducing redundant work in methods package

2015-01-21 Thread Michael Lawrence
Note that setMethod() resolves .BasicFunsList in the methods namespace directly when setting a method on a primitive. Somehow there should be consistency between genericForPrimitive() and the check in setMethod(). Also, we can probably step away from the use of elNamed(), given that [[ now uses ex