# [Rd] "==" for calls and expressions ??

Martin Maechler Martin Maechler <maechler@stat.math.ethz.ch>
Fri, 15 Sep 2000 17:10:33 +0200

```{following up myself on the     NULL == NULL   topic}

I found	that
x == y
is allowed in R when x and y are (generalized) ``Vectors''
(accidentally, I'm quite sure !), which includes
lists and  expressions, but the result is pretty `funny' in some cases, e.g.

> e3 <- expression(1,x,x^2)
> e3 == expression(1,x,x^2)
[1] FALSE  TRUE FALSE
> e3 == e3 ## all TRUE..
[1] TRUE TRUE TRUE

Note that it's not just "==", but all 6 relation operators ( "!=", "<", ...).

It's been quite easy for me to make R produce an error in these cases
{the same as for

> cl <- quote(sin(x)) ; cl == cl
Error in cl == cl : comparison (1) is possible only for vector types
}
But with that "make check" would fail
(we have at least on case in the examples where we test equality of two expr)
and it might be that people's R code already is doing these comparisons
with list()s and expression()s.

What should be done?

--
One possibility would be to make these work for call()s and expressions,
by using deparse(.) on the non-symbol calls
{symbol calls already *do* work -- and this is *not* accidental :

> cl <- as.name("X"); cl == cl; cl > cl
[1] TRUE
[1] FALSE
}
and dealing with expressions as "vector of calls".
It is still less clear how list()s should be dealt with.

We really have the problem of differing
backcompatibility to R and compatibility to S
(in S, these rel.ops only apply to atomic objects and NULL).

Opinions?

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```