assert_is_binding_locked {assertive.code} | R Documentation |
Check to see if the binding of a variable is locked (that is, it has been made read-only).
assert_is_binding_locked(x, severity = getOption("assertive.severity", "stop")) is_binding_locked(x, env = if (is_scalar(e <- find(.xname))) as.environment(e) else parent.frame(), .xname = get_name_in_parent(x))
x |
Input to check. (Unlike |
severity |
How severe should the consequences of the assertion be?
Either |
env |
Environment to check where binding had been locked. |
.xname |
Not intended to be used directly. |
TRUE
or FALSE
, depending upon whether or not the
binding is locked in the specified environment.
assert_is_binding_locked
returns nothing but throws an error if
the corresponding is_*
function returns FALSE
.
The environment is guessed as follows: The name of x
is
determined via get_name_in_parent
. Then find is called,
bindingIsLocked
, which this wraps,
find
for how the environment is guessed. If this returns
a single environment, that is used. Otherwise the parent environment is
used (as determined with parent.frame
).
is_binding_locked(a_non_existent_variable) e <- new.env() e$x <- 1:10 is_binding_locked(x, e) lockBinding("x", e) is_binding_locked(x, e) unlockBinding("x", e) is_binding_locked(x, e)