Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upStrange bug with capturing namespaces #94
Comments
|
@wch If this involves deep digging, can you suggest some workarounds? |
|
The reason it happens is because the One thing you could do for now is simply wrap the function in a list, so that fun_caller = R6::R6Class(
public = list(
initialize = function(f_) self$f = list(f_),
f = list(),
call_f = function(x) self$f[[1]](x)
)
) |
First of all many thanks for the huge amount of work done by
R6developers and contributors.I use
R6v2.1.3.Recently I discovered a strange behaviour of
R6classes (looks like a bug) - when instance of the class is cloned, it can't correctly capture namespace/environment of the member function.Description above can looks unclear, so it will be simpler to consider following example (my use case a little bit more complex - I use
R6to create iterators which can apply some function to the chunk after$next()call):check_input- is a internal function intokenizerspackage and it is not exported!However this works fine:
And this also works: