From simon.urbanek at r-project.org  Thu Oct  1 18:11:36 2009
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Thu, 1 Oct 2009 12:11:36 -0400
Subject: [Rd] creating environments in package's C code
In-Reply-To: <4AC4CBD9.7010309@mx.uni-saarland.de>
References: <4AC4CBD9.7010309@mx.uni-saarland.de>
Message-ID: <05B9BFD2-92DF-4D64-854F-ECBBAF7A0B34@r-project.org>


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().

Cheers,
Simon



[Rd] creating environments in package's C code
Simon Urbanek