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

Jon McAuliffe jon at vindigo.com
Thu Apr 13 16:38:10 CEST 2000



"Dan E. Kelley" wrote:
> 
> > > I have some doubts about the implementation of the operators  '&&'  and
> > > '||'. I only discuss  '&&'  here. The reason: One of my students tried
> 
> One thing I like about Perl is that it defines 'and' and (rhyming
> here, can't help it) 'or' as well as the operators that C programmers
> expect.

perl's 'and' and 'or' were introduced as ultra-low-precedence
operators to accomodate common perl idioms like

 do_foo_successfully(bar) || die("oops");

in cases where the left-hand disjunctive clause might contain
operators that "accidentally" bound less tightly than '||', for
example. they weren't added to increase the syntactic appeal of
the language. to think of 'and' and 'or' as synonymous with '&&' and
'||' will certainly land you in trouble eventually. here again bill
venables's earlier points about appreciating these distinctions
are well taken.

cheers
jon.


> I've known many folks who were confused with & and && in C, but C
> needs both bitwise and logical operators, so we're stuck.
> 
> Speaking of stuck, R is stuck too, since it strives to be like S.  A
> way to improve things might be to provide warnings of things that are
> legal but that might indicate errors of programming.  Perl does this
> quite effectively, which is worth mentioning since it too is caught in
> the bind of sticking with poor choices made in the adolescent stage of
> growth.
> 
> --
> Dan E. Kelley                                         phone:(902)494-1694
> Oceanography Department, Dalhousie University           fax:(902)494-2885
> Halifax, Nova Scotia                             mailto:Dan.Kelley at Dal.CA
> Canada B3H 4J1       http://www.phys.ocean.dal.ca/~kelley/Kelley_Dan.html
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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