Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
It is possible to overwrite methods in R6 objects #19
Once an R6 object has been constructed, it is possible to overwrite its methods, which seems undesirable:
Thing <- R6::R6Class("Thing", public=list( a=1L, f=function() a)) obj <- Thing$new() obj$f() # 1L obj$f <- NULL # is allowed obj$f() # Error: attempt to apply non-function
And of course, putting the method "back" doesn't work because the environment of that function is wrong:
obj$f <- function() a obj$f() # Error: object 'a' not found
Is there any way of easily preventing this happen without sacrificing the speed goals of R6?