[Rd] common base functions stripping S3 class

Hadley Wickham h.wickham at gmail.com
Mon Nov 17 16:41:25 CET 2014

> Generally the idea is that the class should be stripped because R has no
> way of knowing if the new object, for example unique(obj), still has the
> necessary properties to be considered to be of the same class as obj.
> Only the author of the class knows that.  S4 would help a bit here, but
> only structurally (it could detect when the object couldn't possibly be
> of the right class), not semantically.

There are two possible ways that S3 methods could handle subclasses:

* preserve by default (would also have preserve all attributes)
* drop by default

If you could really on either system consistently, I think you could
write correct code. It's very hard when the defaults vary.

(In other words, I agree with everything you said, except I think if
the default was to preserve you could still write correct code)



More information about the R-devel mailing list