[Rd] creating environments in package's C code

Simon Urbanek simon.urbanek at r-project.org
Thu Oct 1 18:11:36 CEST 2009

On Oct 1, 2009, at 11:33 , Martin Becker wrote:

> Dear developers,
> is it possible to create environments in C code of packages?
> Simply using
> SEXP env;
> PROTECT (env  = allocSExp(ENVSXP));
> and assigning the enclosing environment with SET_ENCLOS seems to be  
> insufficient.

Rf_NewEnvironment is the function that does it, e.g.,
Rf_NewEnvironment(R_NilValue, R_NilValue, parent)
it's not part of the official API (headers) but it is visible.
For hashed environments it's R_NewHashedEnv().


More information about the R-devel mailing list