load, environment[[, and attr<-/attributes<- (PR#8457)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

load, environment[[, and attr<-/attributes<- (PR#8457)

MarkBravington
Full_Name: Mark Bravington
Version: 2.2.1
OS: Windows XP
Submission from: (NULL) (203.132.243.69)


#       [hidden email]

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
[hidden email]

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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel