assert_is_binding_locked

0th

Percentile

Is the binding of a variable locked?

Check to see if the binding of a variable is locked (that is, it has been made read-only).

Usage
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))

Arguments
x

Input to check. (Unlike bindingIsLocked, you can pass the variable itself, rather than a string naming that variable.)

severity

How severe should the consequences of the assertion be? Either "stop", "warning", "message", or "none".

env

Environment to check where binding had been locked.

.xname

Not intended to be used directly.

Value

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.

Note

The environment is guessed as follows: The name of x is determined via get_name_in_parent. Then find is called,

See Also

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).

Aliases
  • assert_is_binding_locked
  • is_binding_locked
Examples
# NOT RUN {
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)
# }
Documentation reproduced from package assertive.code, version 0.0-3, License: GPL (>= 3)

Community examples

Looks like there are no examples yet.