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

Peter Dalgaard BSA p.dalgaard@biostat.ku.dk
15 Apr 1999 00:17:11 +0200

Robert Gentleman <rgentlem@hsph.harvard.edu> writes:

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

I'm inclined to agree here. On the other hand, what might be the case
is that you could make class<- be a little more careful with its
argument so that UseMethod would see the modified x. Sneaky, but
compatible, and *perhaps* not very hard to do. How often is this kind
of construct (class(x)<-foo;UseMethod()) used in actual S code?

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

- and Joe User generally gets in trouble with methods anyway...

   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
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