[Rd] Bug in comparison of language objects?
Martin Maechler
m@ech|er @end|ng |rom @t@t@m@th@ethz@ch
Wed Feb 21 10:48:09 CET 2024
>>>>> Duncan Murdoch
>>>>> on Tue, 20 Feb 2024 08:47:30 -0500 writes:
> On 20/02/2024 8:03 a.m., Duncan Murdoch wrote:
>> I noticed the following odd behaviour today:
>>
>> exprs <- expression( mean(a), mean(b), { a }, { b } )
>>
>> exprs[[1]] == exprs[[2]] #> [1] FALSE
>>
>> exprs[[3]] == exprs[[4]] #> [1] TRUE
>>
>> Does it make sense to anyone that the argument passed to
>> `mean` matters, but the expression contained in braces
>> doesn't?
> I have done some debugging, and found the cause: for the
> comparison of language objects, R deparses them to strings
> using C function deparse1(), and looks at only the first
> line. "mean(a)" deparses as is, but "{ a }" deparses to 3
> lines
> { a }
> and the first line is the same as for "{ b }", so they
> compare equal.
> I think it would make more sense to deparse them to one
> long string, and compare those, i.e. to replace deparse1()
> with deparse1line() (which may have been the intention).
> Duncan Murdoch
I agree ... (and more do).
Thank you for adding it as formal report to R's bugzilla,
https://bugs.r-project.org/show_bug.cgi?id=18676
Unfortunately, it triggers something in the (byte) compiler test
suite, and (also/hence) will probably be too late for R 4.3.3.
Martin
Martin Maechler
More information about the R-devel
mailing list