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

Peter Dalgaard BSA p.dalgaard@biostat.ku.dk
15 Apr 1999 23:50:07 +0200

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

>   Does that mean that our implementaion of substitute is not quite
> right? The documentation suggests that you get the expression typed as
> the value of a formal argument; right now we're getting the current
> value.

No. It means that S's implementation is quite wrong...

R's substitute works by fairly clean rules of (lazy) evaluation: If
you pass it a an expression containing x and x is a PROMSXP, you get
the argument expression. If you change x before the substitute, you get
the current value (unless you used x<-delay(something), in which case
you get the unevaluated something). 

S does --- something else:

> f<-function(x){x<-2;substitute(x)}
> f(5)
[1] 2
> y<-5     
> f(y)

This, I *really* don't think we want to emulate.

The documentation is badly off, though... and the quote() doc is
really off target. (I've written about this before, but it never found
its way to the help page, obviously).

   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