[Rd] str() resets class for environments
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Nov 23 16:22:13 CET 2004
On Tue, 23 Nov 2004, Roger D. Peng wrote:
> I noticed the following today --- str() seems to remove any extra class
> information added to an environment.
>
>> e <- new.env()
>> class(e)
> [1] "environment"
>> class(e) <- c("foo", class(e))
>> class(e)
> [1] "foo" "environment"
>> str(e)
> Classes 'foo', 'environment' length 0 <environment>
>> class(e)
> [1] "environment"
>
> I'm not sure if this is related to the external pointer issue mentioned in
> the NEWS file.
It is. Needed essentially the same fix.
> Is this the intended behavior for environments? (It happens
> in today's R-devel also.)
I believe the intention is that you should not class environments. Luke
suggested earlier that unclassing one be made an error, and I have now
done that. Note that environments are not copied, and so everything you
do to one instance you do to all other instances of it. Setting a class
makes little sense for such an object.
--
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
More information about the R-devel
mailing list