mark.bravington@csiro.au
2006-Jan-03 02:07 UTC
[Rd] load, environment[[, and attr<-/attributes<- (PR#8457)
Full_Name: Mark Bravington Version: 2.2.1 OS: Windows XP Submission from: (NULL) (203.132.243.69) # r-bugs at r-project.org There is a bug to do with 'load', environment access via '[[', and 'attr<-' or 'attributes<-'. Modifying the attributes of a *copy* of an object can modify the original too, under certain conditions: - the copy needs to be created using env[[ not by env$ nor just by name - the original object must have been 'load'ed and not subsequently read-accessed before the copy was created The script below might clarify this. BTW the problem is not only for .GlobalEnv. It's intriguing that 'load' doesn't seem to be "fully creating" the object-- is it just creating a promise or something like that? Mark Bravington mark.bravington at csiro.au a <- 1 attr( a, 'thing') <- 99 tf <- tempfile() save( a, file=tf) load( tf) y <- .GlobalEnv[[ 'a']] attr( y, 'thing') <- NULL a # attr gone! load( tf) y <- .GlobalEnv$a attr( y, 'thing') <- NULL a # OK load( tf) a # to force access y <- .GlobalEnv[[ 'a']] attr( y, 'thing') <- NULL a # OK unlink( tf) --please do not edit the information below-- Version: platform = i386-pc-mingw32 arch = i386 os = mingw32 system = i386, mingw32 status = major = 2 minor = 2.1 year = 2005 month = 12 day = 20 svn rev = 36812 language = R Windows XP Professional (build 2600) Service Pack 1.0 Locale: LC_COLLATE=English_Australia.1252;LC_CTYPE=English_Australia.1252;LC_MONETARY=English_Australia.1252;LC_NUMERIC=C;LC_TIME=English_Australia.1252 Search Path: .GlobalEnv, package:methods, package:stats, package:graphics, package:grDevices, package:utils, package:datasets, Autoloads, package:base