Question on S7 base classes

Bert Gunter <[email protected]> Sun, 4 Jan 2026 16:35:11 -0800
Newsgroups gmane.comp.lang.r.general
Message-ID <CAGxFJbRMnNQrbfdaON9Q=zZ7dW8qyNzDgeA248t70V5oUe+Zhw@mail.gmail.com>
Could someone explain the following behavior to me, which I find
inconsistent and confusing:

> inherits(1L, "integer")
[1] TRUE    **as expected. S3 class**
> inherits(1L, class_integer)
[1] TRUE  ** as expected. S7 base class**

> inherits(1.0, "double")
[1] FALSE   ** There is no "double" class in S3
> inherits(1.0, "numeric")
[1] TRUE ** doubles are S3 class "numeric". This is (sort of) documented**

BUT ...
> inherits(1.0, class_double)
[1] FALSE  ** because there is no S3 class "double" ?? **

> inherits(1.0, class_numeric)
Error in inherits(1.2, class_numeric) :
  'what' must be a character vector or an object with a nameOfClass() method
**class_numeric is an S7 union, not an S7 base class ?**

So if 1.0 is not class_double, what base class is it? And how should I test
for the class of a non-integer numeric? And what is class_double then?

My apologies if this is obvious, but as I said, I find this confusing.

Best,
Bert

	[[alternative HTML version deleted]]