From rdpeng at gmail.com  Tue Sep 26 23:56:19 2006
From: rdpeng at gmail.com (Roger D. Peng)
Date: Tue, 26 Sep 2006 17:56:19 -0400
Subject: [Rd] standardization of slot access
In-Reply-To: <87y7s6bbhq.fsf@patagonia.sebmags.homelinux.org>
References: <87y7s6bbhq.fsf@patagonia.sebmags.homelinux.org>
Message-ID: <4519A203.10805@gmail.com>

I think slot() is only necessary in the case where you have

a <- "myslot"
slot(object, a)

which is equivalent to

object at myslot

It seems unlikely that you would use slot() during interactive use, but perhaps 
more so in programming.  Even still, I rather infrequently find the need for 
slot() because classes have defined slot names---if you're going to access a 
slot, just use the name that you gave it in the class definition since that 
doesn't change from instance to instance.

-roger

Sebastian P. Luque wrote:
> Hi,
> 
> I'm usually confused about when to use 'slot' or '@'.  I've frequently
> read that it's always preferable to use accessor functions, so I would
> think the '@' operator should be avoided.  However, ?slot contains the
> following advise:
> 
> 
> "Generally, the only reason to use the functional form rather than the
> simpler operator is _because_ the slot name has to be computed."
> 
> 
> How do we decide whether to use the function or the operator?
> 
> 
> Cheers,
> 

-- 
Roger D. Peng  |  http://www.biostat.jhsph.edu/~rpeng/




[Rd] standardization of slot access
Roger D. Peng