[Rd] [External] Re: Could .Primitive("[") stop forcing R_Visible = TRUE?
iuke-tier@ey m@iii@g oii uiow@@edu
iuke-tier@ey m@iii@g oii uiow@@edu
Fri Oct 25 18:50:34 CEST 2024
On Fri, 25 Oct 2024, Ivan Krylov via R-devel wrote:
> В Fri, 25 Oct 2024 08:39:39 -0400
> Duncan Murdoch <murdoch.duncan using gmail.com> пишет:
>
>> Surely you or they should be the ones to run the test across all of
>> CRAN?
>
> That's fair. The question is, is there a fundamental reason I
> overlooked to deny such a change? Except for positioning and
> whitespace, the line has been in names.c since SVN revision 2. The
> one regression test touched by the change has been there since 2010.
A couple of points first:
In principle you would need a _much_ stronger case for the
benefits of a change like this relative to the cost of breaking
backward compatibility of output. Checking CRAN/BIOC for impact
would be good to do, but test coverage of output in package tests
isn't great, and this doesn't get at changes in script and report
output.
Changing just [ would create an inconsistency with the other
extractors [[, $, and @. Changing all would affect more output.
Many, maybe most, primitives have byte code instructions that are
used by compiled code. You need to check and possible change both
the interpreted and the compiled execution paths.
However: it looks like the byte code engine implementation for the
extraction instructions does not set the visible flag for a successful
dispatch. A simple example:
x <- structure(1, class = "foo")
`[.foo` <- function(x, i) invisible(2)
withVisible(x[1])
## $value
## [1] 2
##
## $visible
## [1] TRUE
withVisible(eval(compiler::compile(quote(x[1]))))
## $value
## [1] 2
## $visible
## [1] FALSE
So there is a discrepancy between interpreted and compiled code which
is a bug that ideally should be resolved. I suspect changing the
compiled code behavior would be more disruptive than changing the
interpreted code behavior, but that would need some looking into.
Filing a bug report on the discrepancy would be a good next step.
Best,
luke
--
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