Re: [Rd] str() resets class for environments

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Wed 24 Nov 2004 - 02:22:13 EST

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

______________________________________________
R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Wed Nov 24 02:51:41 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 09:01:41 EST