Use an environment as the base type of an S7 class
Source:R/base-environment.R
class_environment.Rdclass_environment is the base wrapper for environments.
Unlike all other R objects, environments have reference semantics, i.e., they
are modified in place. It's not clear what all the implications of this are
for S7, so we are marking the use of class_environment as experimental.
Its use is subject to the following caveats:
Examples
Counter := new_class(class_environment)
counter <- Counter()
counter$n <- 0L
# Reference semantics: `copy` and `counter` are the same object, so
# mutating one is visible through the other.
copy <- counter
copy$n <- 10L
counter$n
#> [1] 10