[R] "privileged slots",

Torsten Steuernagel Torsten.Steuernagel at gmx.de
Thu May 27 22:55:20 CEST 2004


On 27 May 2004 at 19:12, Wolski wrote:

> But this document is quite intersting.

Which document are you refering to ?
 
> I have just two R questions which arised reading the document which a
> core members of the R-project cant find. 

I can't find it either.

> 1. Is it intended to introduce privileged slots in the future version of
> R?

You are talking about access control like C++ (private, protected, 
public) has, aren't you ? I can't answer for the R Core Team but I'm 
also interested in a similar functionality. Please check the setClass() 
docs for the "access" argument. I suppose this is intended to provide 
such functionality in the future.
 
> 2. Is it true
> that one can gain execution speed by accessing slots using the
> function slots(object,name,check=FALSE)<-value would speed up
> execution?

Try this:

> get("@<-")
function (object, name, value) 
{
    arg <- substitute(name)
    if (is.name(arg)) 
        name <- as.character(arg)
    "slot<-"(object, name, TRUE, value)
}

So "@<-" actually calls "slot<-". Using "slot<-" instead, you save the 
additional overhead the call to "@<-" introduces. If there will be a real 
performance gain in replacing "@<-" certainly depends on what you're 
doing.

- Torsten




More information about the R-help mailing list