Skip to content
Prev 21320 / 63424 Next

attributes of environments

On 7/5/06, Thomas Lumley <tlumley at u.washington.edu> wrote:
I don't think this follows since in the other cases modifying the
object also creates a copy.
I don't think that that would solve it because there is still the issue
of the class attribute which you can't disallow.

In fact consider this:

e <- new.env()
f <- e
class(f) <- c("myenv", "environment")
F <- function(x) UseMethod("F")
F.environment <- function(x) 1
F.myenv <- function(x) 2
F(e) # 2
F(f) # 2

The point is that subclassing does not work properly with environments
yet subclasses of the environment class should be possible since R
is supposed to be OO and I see no valid reason for exclusing environments
for this.  I guess in this discussion I am coming to the realization that
this issue really is a problem with the current way R works.