[R-pkg-devel] [External] May .External2() be used in packages?

Konrad Rudolph konr@d@rudo|ph @end|ng |rom gm@||@com
Wed May 1 21:59:05 CEST 2024


Hi Luke,

Thanks, obviously that will work and I didn’t think of it.

In my defence I had previously used match.call() to capture the call on the
R side, and representative microbenchmarks show that it adds a prohibitive
overhead for my use-case. On the C side I only need the caller information
in the non-performance sensitive path (for error message formatting) so I
can compute it on demand. And I hadn’t included .External2() in that
benchmark yet. I assume that it’ll be no faster than the way you proposed,
so it isn’t actually needed in my case — just as you said.


On Wed, 1 May 2024 at 21:32, <luke-tierney using uiowa.edu> wrote:

> yOn Wed, 1 May 2024, Konrad Rudolph wrote:
>
> > Thanks,
> >
> > That’s a shame but good to know.
> >
> >       Packages that for whatever reason have chosen to use it
> >       could instead use .External(), and that is what yo should use.
> >
> >
> > Unfortunately .External() is not a replacement (in general, or for my
> > purpose) since it’s missing the `call` and `rho` arguments, and computing
> > the same information without these arguments in C code is far from
> trivial.
>
> The call you would get is not likely to be all that useful, but it is
> the one you wrote. The environment is the one you get from environment()
> at the point where you would call .External2. So instead of
>
> .External2("foo", x, y)
>
> do
>
> .External("foo", quote(.External2("foo", x, y)), environment(), x, y)
>
> and adjust your C function accordingly.
>
> Best,
>
> luke
>
> > --
> > Konrad Rudolph // @klmr
> >
> >
>
> --
> 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



-- 
Konrad Rudolph // @klmr

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list