[Rd] locked environments

William Dunlap wdunlap at tibco.com
Wed Apr 20 20:58:47 CEST 2016


Shouldn't the following 4 ways to alter an object in a locked environment
either all work or all fail?  (All working would be nice, I think.)

   E <- new.env()
   assign("var", c(1,2,3,4), envir=E)
   lockEnvironment(E, bindings=FALSE)
   E$var[1] <- 101 ; E$var
   #[1] 101   2   3
   local(var[2] <- 102, envir=E)
   #Error in eval(expr, envir, enclos) :
   #  cannot add bindings to a locked environment
   with(E, var[3] <- 103)
   #Error in eval(expr, envir, enclos) :
   #  cannot add bindings to a locked environment
   eval(quote(var[4] <- 104), envir=E)
   #Error in eval(expr, envir, enclos) :
   #  cannot add bindings to a locked environment
   get("var", envir=E)
   #[1] 101   2   3   4


Bill Dunlap
TIBCO Software
wdunlap tibco.com

	[[alternative HTML version deleted]]



More information about the R-devel mailing list