Just a suggestion: it might be worth considering if the error message could be a bit more informative when trying to assign a value to active fields whose binding functions don't take any arguments.
Consider the following example:
MyClass <- R6Class(
classname = "MyClass",
public = list(
x = "character",
initialize = function(
x = "a"
) {
self$x <- x
}
),
active = list(
y = function() file.path(self$x, "b")
)
)
inst <- MyClass$new()
inst$x
inst$y
The binding function of y does not take any arguments as it's supposed to be strictly dependent on x,
You tried to assign a value to an active field that does not support this (strict dependency)
AFAIK, this would need to be supplied somewhere in the call to makeActiveBinding(). Probalby something along the lines of this:
makeActiveBinding(
"test",
env = .GlobalEnv,
function(v) {
if (missing(v)) {
print("Execute the binding function")
} else {
stop("You tried to assign a value to an active field that does not support this (strict dependency)")
}
}
)
> test
[1] "Execute the binding function"
> test <- "a"
Error in (function (v) :
You tried to assign a value to an active field that does not support this (strict dependency)
Just a suggestion: it might be worth considering if the error message could be a bit more informative when trying to assign a value to active fields whose binding functions don't take any arguments.
Consider the following example:
The binding function of
y
does not take any arguments as it's supposed to be strictly dependent onx
,Here, something like this might be better:
AFAIK, this would need to be supplied somewhere in the call to
makeActiveBinding()
. Probalby something along the lines of this: