hadley / r-internals

Documentation for R's internal C API
346 stars 40 forks source link

Add `R_NewEnv`, a C version of `new.env()` #22

Closed yutannihilation closed 3 years ago

yutannihilation commented 3 years ago

Writing R Extensions now has this sentence:

At times it may also be useful to create a new environment frame in C code. R_NewEnv is a C version of the R function new.env:

SEXP R_NewEnv(SEXP enclos, int hash, ins size)

It seems this was added by the following commit (without a notice on changelog...?), and the API is available as of R 4.1. I haven't used this yet, but probably it would be nice to cover this in R internals.

https://github.com/wch/r-source/commit/8a322e786068ec2e23324e61821ff666d0b6e329

mattfidler commented 3 years ago

Rcpp used this funtion and it triggered a R CMD CHECK error. I am guessing it doesn't anymore?

On Sat, Jul 17, 2021, 11:46 PM Hadley Wickham @.***> wrote:

Merged #22 https://github.com/hadley/r-internals/pull/22 into master.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/hadley/r-internals/pull/22#event-5034664782, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAD5VWQSQJU5XGY5XHQ4RC3TYJMCDANCNFSM5ARVH5MA .

mattfidler commented 3 years ago

I could be wrong the funtion name was different.

https://github.com/RcppCore/Rcpp/issues/771

yutannihilation commented 3 years ago

R_NewHashedEnv is called internally in R_NewEnv :)

https://github.com/wch/r-source/blob/023e230ae3f237d2fd75aa478bccceca60848871/src/main/envir.c#L3609