I've been trying to add classes and attributes to symbol objects (created with quote()), and the behavior is very strange, as illustrated in the examples below.
If symbols aren't meant to have classes and attributes attached to them, then perhaps R should throw errors when you attempt to do it? # Using str() strips class from object x <- quote(foo) class(x) <- "bar" str(x) # Class 'bar' symbol foo str(x) # symbol foo # Attempting to overwrite doesn't affect class. # str() still strips class from the object. x <- quote(foo) class(x) <- "bar" x <- quote(foo) str(x) # Class 'bar' symbol foo str(x) # symbol foo # Changing class of one object affects other x <- quote(foo) y <- quote(foo) class(x) <- "bar" class(y) # [1] "bar" str(y) # Class 'bar' symbol foo str(y) # symbol foo str(x) # symbol foo # Changing attribute of one object affects other # Unlike with class, str() doesn't cause other attributes to disappear x <- quote(foo) y <- quote(foo) attr(x, "a") <- "bar" str(y) # length 1 foo # - attr(*, "a")= chr "bar" str(y) # length 1 foo # - attr(*, "a")= chr "bar" str(quote(foo)) # length 1 foo # - attr(*, "a")= chr "bar" -Winston ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel