Skip to content
Prev 44553 / 63421 Next

inconsistencies between ?class and ?UseMethod

Herv? Pag?s <hpages at fhcrc.org> writes:
It still is in the sense that UseMethod and NextMethod dispatch in that
manner on implicit classes. It is bit confusing to me that class()
doesn't report all the implicit classes (like the first error message
below) and inherits() only admits what class() has told.

Note what the first error message below says and how the succesive calls
for afun() work as methods are added to the generic.

If you set a class attribute then the picture changes. I do not see where
this is documented, but it looks like once a class attribute is set, the
implicit classes go away - per the last error message.
Error in UseMethod("afun", x) : 
  no applicable method for 'afun' applied to an object of class
  "c('matrix', 'integer', 'numeric')"
numeric 1
integer 1
matrix 1
integer 1
matrix 1
Error in NextMethod() : no method to invoke
I wonder if "except with implicit" would improve over "with some
interpolated" in ?class here:

"...in R UseMethod dispatches on the class as returned by class (with
some interpolated classes: see the link)"

HTH,

Chuck