From pgilbert@bank-banque-canada.ca  Fri Sep 15 21:14:26 2000
From: pgilbert@bank-banque-canada.ca (Paul Gilbert)
Date: Fri, 15 Sep 2000 16:14:26 -0400
Subject: [Rd] classed
References: <3.0.32.20000915142129.0129d2d0@pophost.nsw.cmis.csiro.au> <20000915165809.I24267@ftoomsh.progsoc.uts.edu.au> <39C245E0.A2B36FA6@bank-banque-canada.ca> <6rn1h9mtsf.fsf@franz.stat.wisc.edu>
Message-ID: <39C28322.4F5F5685@bank-banque-canada.ca>



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


[Rd] classed
Paul Gilbert