From rgentlem@hsph.harvard.edu  Wed Apr 14 15:29:54 1999
From: rgentlem@hsph.harvard.edu (Robert Gentleman)
Date: Wed, 14 Apr 1999 10:29:54 -0400 (EDT)
Subject: R's UseMethod() does not dispatch on changed class() (PR#167)
In-Reply-To: <199904140923.LAA25445@biostat.ku.dk>
Message-ID: <Pine.SV4.4.05.9904141016170.18981-100000@hsph.harvard.edu>


I'm pretty sure we've been through this one several times already,
although probably in different guises.
The discussion in the white book, section A.6 is rather specific about
this. And as near as I can tell is contrary to what S does. I don't think
that you want to do what S does.

Do you really want to have a language that accepts any change in x?
It is rather hard to see how it's object oriented then!
Or, alternatively do you really want to see if the only thing that
has changed about x is its class and that will be ok?
What about the other arguments?
The whole point of UseMethod is that we got an object x, with a
particular class and now we're going to do the right thing.
If you wanted to do the right thing with an object of a different
class then you need to do that before you call UseMethod.

Basically, one of the differences between UseMethod and NextMethod is
that with the first you don't get to change anything in the body of
the function, or at least, if you do then it will be ignored. If you
want to change things, do so and then call the generic.

UseMethod believes that the x in the call was evaluated and will
use that value in the call to the method.
NextMethod looks in the local environment for an x, uses one if it
finds one (otherwise gets the x in the call).
Semantically different, well documented and if Joe User doesn't
understand it's because S doesn't do what it says it does and
people write bad code (but generally not as bad as mine ;-).


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


R's UseMethod() does not dispatch on changed class() (PR#167)
Robert Gentleman