iuke-tier@ey m@iii@g oii uiow@@edu
2024-Mar-04 16:45 UTC
[Rd] Ordered comparison operators on language objects will signal errors
Comparison operators == and != can be used on language objects (i.e. call objects and symbols). The == operator in particular often seems to be used as a shorthand for calling identical(). The current implementation involves comparing deparsed calls as strings. This has a number of drawbacks and we would like to transition to a more robust and efficient implementation. As a first step, R-devel will soon be modified to signal an error when the ordered comparison operators <, <=, >, >= are used on language objects. A small number of CRAN and BIOC packages will fail after this change. If you want to check your packages or code before the change is committed you can run the current R-devel with the environment variable setting _R_COMPARE_LANG_OBJECTS=eqonly where using such a comparison now produces > quote(x + y) > 1 Error in quote(x + y) > 1 : comparison (>) is not possible for language types 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 at uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu
Henrik Bengtsson
2024-Mar-05 02:03 UTC
[Rd] Ordered comparison operators on language objects will signal errors
On Mon, Mar 4, 2024 at 8:45?AM luke-tierney--- via R-devel <r-devel at r-project.org> wrote:> > Comparison operators == and != can be used on language objects > (i.e. call objects and symbols). The == operator in particular often > seems to be used as a shorthand for calling identical(). The current > implementation involves comparing deparsed calls as strings. This has > a number of drawbacks and we would like to transition to a more robust > and efficient implementation. As a first step, R-devel will soon be > modified to signal an error when the ordered comparison operators <, > <=, >, >= are used on language objects. A small number of CRAN and > BIOC packages will fail after this change. If you want to check your > packages or code before the change is committed you can run the > current R-devel with the environment variable setting > > _R_COMPARE_LANG_OBJECTS=eqonlyA minor comment, which or may not matter, depending on how long you're planning to keep that variable around. I believe all other "internal" environment variables in the R source code that starts with _R_ also ends with an underscore (_). This name is an outlier in that sense. So, maybe it should be named '_R_COMPARE_LANG_OBJECTS_' instead? (I checked the source code - it's indeed without the trailing underscore). /Henrik> > where using such a comparison now produces > > > quote(x + y) > 1 > Error in quote(x + y) > 1 : > comparison (>) is not possible for language types > > 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 at uiowa.edu > Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel
Reasonably Related Threads
- [R] Fwd: Help: malloc/free deadlock in unsafe signal handler 'Rf_onsigusr1'
- [External] Mitigating Stalls Caused by Call Deparse on Error
- [External] Mitigating Stalls Caused by Call Deparse on Error
- [External] Missing function Rf_findFun3
- switch to reference counting in R-devel