[R-pkg-devel] Using DOTS from C API
Duncan Murdoch
murdoch@dunc@n @end|ng |rom gm@||@com
Mon Aug 18 21:45:49 CEST 2025
On 2025-08-18 2:25 p.m., Josiah Parry wrote:
> *Question:* what is the best way to access a DOTSXP from R's C API in a
> function call.
>
> Over at extendr (1) we'd like to be able to utilize `...` from the body of
> a Rust function—with initial motivation being to support S3 generics like
> print(x, ...).
>
> I don't see any recommendations / or mention of accessing DOTSXP in WRE.
> The closest I can find is from R internals (2) repo which says
>
> "Easiest to get to with findVar(R_DotsSymbol, env) or similar."
>
>
> From R's C API would this mean we would want to use something like:
>
> findVar(R_DotsSymbol, R_GetCurrentEnv()) to get the dots pairlist from the
> function's environment?
>
It's almost certainly easier to pass something like list(...) to your
external function. That will evaluate each of the arguments in the
appropriate environments and put them in a list.
If you want to receive the promises without them being evaluated, I
don't know if there's a documented way to do it in the C API. You could
always use the tidyverse approach and ask your users to pass formulas
instead of expressions.
Duncan Murdoch
More information about the R-package-devel
mailing list