R-alpha: ==NULL

Thomas Lumley thomas@biostat.washington.edu
Thu, 1 May 1997 09:28:48 -0700 (PDT)

On Thu, 1 May 1997, Martin Maechler wrote:

> >>>>> "Tom" == Thomas Lumley <thomas@biostat.washington.edu> writes:
	^^^^^ Aaargh! Not "Tom", please.
>     Tom> Any comparison with NULL generates an error Error: comparison is
>     Tom> possible only for vector types whereas in S(-PLUS) it gives NA,
>     Tom> which seems more sensible.
>     Tom> Along similar lines, comparison with a length 0 vector returns
>     Tom> logical(0) in R but NA in S.
> Is n't  logical(0)  more  logical than  NA ?

I didn't (previously) make any comment on this -- I only said that NA was
more logical than an error message.  However, the advantage of returning
NA is that NA | TRUE is TRUE, NA & FALSE is FALSE, which doesn't happen
with logical(0). Also, from a compatibility point of view one of them is
tested with is.na(), the other with length(), so it can matter which one
you use.  Of course no-one should deliberately write code where it
matters, but these things happen. 

It seems in fact that logical(0) | TRUE causes R to freeze (R0.49,
sparc solaris).

Thomas Lumley
Biostatistics		: "Never attribute to malice what  :
Uni of Washington	:  can be adequately explained by  :
Box 357232		:  incompetence" - Hanlon's Razor  :
Seattle WA 98195-7232	:				   :

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