[R] Can we get rid of && and ||?

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Apr 13 14:38:09 CEST 2000


> Date: Thu, 13 Apr 2000 14:21:14 +0200 (CEST)
> From: GB <gb at stat.umu.se>
> 
> Brian,
> 
> thanks for your comments. I have only one question/remark:
> 
> [snip]
> > > Provided there are no other differences, I suggest that either
> > > 
> > > a) '&&'  is made obsolete, and  '&'  is 'improved' so that  b  in
> > >    'a & b' is evaluated only if some component of  a  is TRUE, or
> > 
> > That would break S compatibility and a lot of correctly written code
> > (including in R itself).
> 
> I meant keeping  '&&'  for precisely that reason, but changing  '&'  as

Ah, that's not what I understood by `made obselete'. 
(`obsolete' = `disused', `discarded', ..., Concise Oxford Dictionary.)

> indicated, so that new code never had to consider '&&'. So, I made two
> assumptions here: (i) Old code (or S code) will not be disturbed by the
> 'improvement' of  '&'; (ii) New code can always use '&' instead of '&&'.
> 

Strictly (i) is false. Suppose I wrote

changed <- x[(n1 <- new(some)) | (n2 <- new(someother))]

Obscure, but legal S code. If n1 is all true, n2 would not be created,

> Of course, if either assumption is wrong, the idea is not so good.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list