[Rd] classed

Paul Gilbert pgilbert@bank-banque-canada.ca
Fri, 15 Sep 2000 16:14:26 -0400



TL>For interpreted "foo<-" functions this wouldn't be true -- the same
TL>amount of copying would be done either way -- but class() is special.

DB>Assignment functions like "class<-" are allowed to modify their first
DB>argument in place.  That's the whole reason for using constructions
DB>like foo[] <- bar, which is really a call to "[<-" with arguments foo
DB>and bar, instead of foo <- bar.  It saves on copying.

Doug
These seem slightly different (but I've already demonstrated that I don't
understand this, so maybe they're not).  I don't think that what you are saying
is true in general or there would be no "back out" of the function below, and
there is.  I can believe that class is special (and this would be an arguement
for classed being in the base and special too). But if it was special when I did
timing tests I'm a bit surprized that I didn't find much difference.

> "test<-" <- function(x, value) {attr(x, "zot") <-  value ; stop(); x}
> x  <- 2
> test(x) <- 5
Error in test<-(*tmp*, value = 5) :
> x
[1] 2
> attr(x, "zot")
NULL
>

Paul Gilbert

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