From pgilbert@bank-banque-canada.ca  Fri Sep 15 16:53:04 2000
From: pgilbert@bank-banque-canada.ca (Paul Gilbert)
Date: Fri, 15 Sep 2000 11:53:04 -0400
Subject: [Rd] classed
References: <3.0.32.20000915142129.0129d2d0@pophost.nsw.cmis.csiro.au> <20000915165809.I24267@ftoomsh.progsoc.uts.edu.au>
Message-ID: <39C245E0.A2B36FA6@bank-banque-canada.ca>

>> classed <- function (x, cls)
>> {
>>     class(x) <- cls
>>     x
>> }

>If it doesn't use copy-on-write then the result will be additional
>slowdown when all your data is copied again and again (I guess it depends
>on how big the object is).

I've often wondered about this. Any comments from someone who really knows the
internals of R? When I first implemented it I did some testing and didn't notice
any really big slowdown and I do use a lot of fairly big (multi MB size)
objects. But notice that the difference is really in the function call, not in
the copying of objects. A function using classed would end

  classed(x, "whatever") }

rather than

 class(x) <- "whatever"
 x}

I think the copy is (or is not) made in both cases.

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