From winstonchang1 at gmail.com  Mon Aug 11 03:46:59 2014
From: winstonchang1 at gmail.com (Winston Chang)
Date: Sun, 10 Aug 2014 20:46:59 -0500
Subject: [Rd] Error when assigning value in environment which is a locked
	binding
Message-ID: <CAFOpNVFrbLFjv0xf78bLfx_Q5e6K4REFX=zxysLTKuQLJbxxmQ@mail.gmail.com>

If an environment x contains a locked binding y which is also an
environment, and then you try to assign a value to a binding inside of
y, it can either succeed or fail, depending on how you refer to
environment y.

x <- new.env()
x$y <- new.env()
lockEnvironment(x, bindings = TRUE)

# This assignment fails
x$y$z <- 1
# Error in x$y$z <- 1 : cannot change value of locked binding for 'y'

# Saving x$y to another variable, and then assigning there works
y2 <- x$y
y2$z <- 10  # OK
print(x$y$z)
# 10


Is this a bug or a feature? I realize that x$y is a locked binding
while y2 is not.

-Winston



[Rd] Error when assigning value in environment which is a locked binding
Winston Chang