[Rd] Discrepancy between is.list() and is(x, "list")

Abs Spurdle @purd|e@@ @end|ng |rom gm@||@com
Fri Mar 29 04:09:51 CET 2019


I know I said that I had no further comments on object oriented semantics.
However, I found a contradiction in the R documentation.


Gabriel Becker wrote:
> So, there are implicit classes, but *only when the data object is NOT an
"R object"

In the R Language Definition:
> The R specific function typeof returns the type of an R object.
> Lists have elements, each of which can contain any type of R object
> Symbols refer to R objects.
> Unlike most other R objects, environments are not copied

So, according the the R Language Defintion, all objects in R, are R objects.

However, in the help page for UseMethod(), which you've already mentioned:
> An R object is a data object which has a class attribute (and this can be
tested by is.object).

So, according to this, an object in R, isn't necessarily an R object.

These are contradictory to each other.
And I believe that the R Language Definition is correct.
So, the help page for UseMethod() should be changed to match the language
definition.


Hadley Wickham wrote:
> Understanding the distinction between base types and S3 classes
> is very important to make this sort of question precise

Note that the R Language Definition does not mention either "base types" or
"S3 classes".
So, should I be understanding *your* distinction between them?


Martin Maechler wrote:
> I do agree with Gabe that (in some cases), using
> formal (aka "S4") classes is really what one should do

S4 doesn't always do intuitive things, either.

Try the following example:
> library (Matrix)
> m = Matrix (1:24, 4, 6)

> #expected output
> print (m)

> #not expected output
> print (m, quote=FALSE)

However, I still may consider using S4, especially where I would otherwise
use a named list.

	[[alternative HTML version deleted]]



More information about the R-devel mailing list