Skip to content

Conversation

@perrydv
Copy link
Contributor

@perrydv perrydv commented Dec 12, 2025

This PR sets the parent_env of 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 nClass parent_env when 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_env that is the package namespace. In the writePackage scheme, the R6 interface class code goes into the package source code and then does not have its parent env manipulated.

@perrydv perrydv merged commit 5978d82 into main Dec 12, 2025
5 checks passed
@perrydv perrydv deleted the R6interface-parent_env branch December 12, 2025 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants