Make nClass interfaces (R6 classes) use the same scoping for compiled as uncompiled #96
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR sets the
parent_envof the R6 class generated to interface to a compiled nClass object to achieve the same scoping as the uncompiled nClass. There is one environment layer in between that provides the chance to place objects that will be found before scoping reaches to the uncompiled nClassparent_envwhen looking for a name. This change means that if an Rpublic function (including initialize) relies on scoping to find a non-member object, that will work in the compiled interface class as well. For example, this is relevant if an nClass is created in a function and uses local variables in that function, to be found by lexical scoping.This has no effect and is much less relevant for package development anyway. In that case, typically, both the nClass and its compiler R6 interface would have
parent_envthat is the package namespace. In thewritePackagescheme, the R6 interface class code goes into the package source code and then does not have its parent env manipulated.