[Rd] standardization of slot access

Tony Plate tplate at acm.org
Wed Sep 27 01:04:53 CEST 2006


I believe that the "accessor" functions you've read about are not the 
slot() function, rather they are functions specifically designed for 
extracting certain data from an object.  An example is the 'coef()' 
extractor function, which extracts coefficients from many model objects. 
  The name of the accessor function need not bear any resemblance to the 
actual name of the slot in which the data is stored, and indeed, there 
does not even need to be a one-to-one relationship between accessor 
functions and slots.

AFAIK, slot() and '@' can be regarded as syntactic variants (please 
correct me if I'm wrong).

-- Tony Plate

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,
>




More information about the R-devel mailing list