[Rd] [External] defer removal of ENCLOS, FRAME, HASHTAB, SET_ENCLOS?

iuke-tier@ey m@iii@g oii uiow@@edu iuke-tier@ey m@iii@g oii uiow@@edu
Mon Mar 23 23:53:00 CET 2026


On Mon, 23 Mar 2026, Thomas Friedrichsmeier wrote:

> [You don't often get email from thomas.friedrichsmeier using kdemail.net. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> Am Sun, 22 Mar 2026 14:05:47 -0500 (CDT)
> schrieb luke-tierney--- via R-devel <r-devel using r-project.org>:
> [...]>
>>> rs <- "/Applications/RStudio.app/Contents/Resources/app/bin/rsession-arm64"
>>> subset(tools:::checkObjAPI(rs), type == "F" & is.na(apitype))$name
>>   [1] "ATTRIB"              "BODY"                "CLOENV"
>>   [4] "ENCLOS"              "FORMALS"             "FRAME"
>>   [7] "HASHTAB"             "locale2charset"      "NAMED"
>> [10] "OBJECT"              "PRCODE"              "PRENV"
>> [13] "PRVALUE"             "R_findVarLocInFrame" "R_lsInternal"
>> [16] "RDEBUG"              "Rf_findVar"          "Rf_findVarInFrame"
>> [19] "Rf_findVarInFrame3"  "Rf_sortVector"       "SET_ENCLOS"
>> [22] "SET_NAMED"           "SET_PRVALUE"         "SET_RDEBUG"
>> [25] "SYMVALUE"
>>> subset(tools:::checkObjAPI(rs), type == "V" & is.na(apitype))$name
>> [1] "R_InputHandlers"  "R_SignalHandlers" "SaveAction"
>>
>> If you think some of these should be in the API you can make a case
>> for that.
>
> Writing for RKWard, we are using the promise-related functions (PRCODE, PRENV,
> PRVALUE, and their SET-equivalents). Our use case is to allow to "peek" into
> bindings without (permanently) forcing them (debugger, object browser, code
> completion). I.e. after evaluation we try to restore the original promise
> (naturally, not all side effects can be undone, but for the most part, this
> does what we want). I am not aware of an existing replacement. One conceivable

The Writing R Extensions manual (WRE) lists a new API for examining
bindings. This was developed in PR18928 on bugzilla.

> replacement for our use case would be a single function to make a
> deep/independent copy of an unevaluated promise.

Promises were never intended to be visible in package C code, and we
are now working towards enforcing that so we can explore more
efficient representations of deferred bindings.

> We are also using R_lsInternal(3), and Rf_findVarInFrame. These can certainly
> be replaced, but are highly convenient. To a lesser extent the same goes for
> FORMALS. IIRC, our motivation for using that was simply performance, although I
> do not recall how much of a difference it made.

R_lsInternal3 is in the API. WRE has pointers for replacing
Rf_findVarInFrame.

> Further we are using R_InputHandlers, in conjunction with addInputHandler and
> R_runHandlers. I would have to evaluate that (old) code quite carefully, but
> we do need the ability to insert our own handlers into the event loop as well
> as running all existing handlers.

These are in the embedding API; see WRE.

Best,

luke

> Regards
> Thomas
>

-- 
Luke Tierney
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
    Actuarial Science
241 Schaeffer Hall                  email:   luke-tierney using uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu



More information about the R-devel mailing list