Re: [R-pkg-devel] [External] May .External2() be used in packages?
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, 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 andFax: 319-335-3017 > Actuarial Science > 241 Schaeffer Hall email: luke-tier...@uiowa.edu > Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu -- Konrad Rudolph // @klmr [[alternative HTML version deleted]] __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel
Re: [R-pkg-devel] [External] May .External2() be used in packages?
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 andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel
Re: [R-pkg-devel] [External] May .External2() be used in packages?
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. -- Konrad Rudolph // @klmr [[alternative HTML version deleted]] __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel
Re: [R-pkg-devel] [External] May .External2() be used in packages?
.External2() is not in the API and is not intended to be used in packages. Packages that for whatever reason have chosen to use it could instead use .External(), and that is what yo should use. I don't expect that to be enforced by the check code soon, but it might be. [.External2() exists for historical reason to ease moving things that used to be primitives in base out into packages where they fit more naturally. It could be removed now, but I don't think that is high on anyone's priority list.] Best, luke On Wed, 1 May 2024, Konrad Rudolph wrote: Hello, Is the `.External2()` function part of the public API, and can it be used in R packages submitted to CRAN? I would like to start using it in a package, and there *are* packages on CRAN which use it. But its man page [1] calls it “internal”, R-exts doesn’t mention it at all (unlike `.C()`, `.Call()` and `.External()`), and it doesn’t have any actual documentation. In the context of the recent tightening of the C API CRAN rules, this makes me concerned that `.External2()` might be next on the chopping block. [1] https://stat.ethz.ch/R-manual/R-devel/library/base/html/Foreign-internal.html Cheers, -- Luke Tierney Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu/ __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel