From h.wickham at gmail.com  Mon Nov 17 16:41:25 2014
From: h.wickham at gmail.com (Hadley Wickham)
Date: Mon, 17 Nov 2014 09:41:25 -0600
Subject: [Rd] common base functions stripping S3 class
In-Reply-To: <54694BDA.10102@gmail.com>
References: <CA+YV+Hx1qA_+JZ1QLo0D7Ckcc3A2sxa-ScAs5g44icfiO4DpnQ@mail.gmail.com>
	<54694BDA.10102@gmail.com>
Message-ID: <CABdHhvEo0OfXC0-rfSJmiyh9XJ57MqCnWDpa3Buwfr0OOzdh4w@mail.gmail.com>

> 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)

Hadley

-- 
http://had.co.nz/



[Rd] common base functions stripping S3 class
Hadley Wickham