From ripley at stats.ox.ac.uk  Wed May 30 19:35:42 2007
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Wed, 30 May 2007 18:35:42 +0100 (BST)
Subject: [Rd] S4 assignment \alias and \usage
In-Reply-To: <m2abvmfety.fsf@ziti.local>
References: <465D7BB2.3050405@bank-banque-canada.ca>
	<18013.34742.228595.528262@stat.math.ethz.ch>
	<465D937F.80207@bank-banque-canada.ca> <m2abvmfety.fsf@ziti.local>
Message-ID: <Pine.LNX.4.64.0705301744450.11532@gannet.stats.ox.ac.uk>

On Wed, 30 May 2007, Seth Falcon wrote:

> Paul Gilbert <pgilbert at bank-banque-canada.ca> writes:
>
>> Let me back up a bit, I may be making another mistake.  My code has
>>
>> setGeneric("TSdoc<-",
>>    def= function(x, value) standardGeneric("TSdoc<-"),
>>    useAsDefault= function (x, value) {attr(x, "TSdoc") <- value ; x })
>>
>> setGeneric("TSdoc",
>>    def= function(x) standardGeneric("TSdoc"),
>>    useAsDefault= function(x) attr(x, "TSdoc"))
>
> Aside:
>
> It seems odd to me to define such defaults.  How do you know x is
> going to have a TSdoc attribute?

I don't think you do, but then you extract NULL if it does not do so.

This is just what names(), comment() ... would do if they were not 
internal functions and you converted them to S4 generics, so this seems 
fairly natural to me (at least if there are legacy objects about that 
need to be handled).

The issue of attributes on S4 objects is one that I consider still open: R 
and S4 differ in implementation but the issue seems undocumented in R.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] S4 assignment \alias and \usage
Prof Brian Ripley