From: John Chambers (jmc@research.bell-labs.com)
Date: Sat 07 Jul 2001 - 23:50:05 EST
Message-id: <3B47138D.451FC180@research.bell-labs.com>
If memory serves, one main reason we allowed (silent) conversion from
logical (FALSE, TRUE) to numeric (0, 1) was for indexing. Programming
tricks of the form of:
c("negative", "positive")[ (x >= 0) + 1]
Not that I'm advocating this as good practice, but it provided a compact
way to generate information. (and, yes, we picked up Fortran (and APL)
style indexing from 1 rather than C style indexing from 0, so we did
need to add the 1)
Converting logical to numeric and then using the result in a comparison
operation, as opposed to an arithmetic operation, seems unlikely to be
what the user intended, on the other hand. As Duncan Murdoch commented,
putting out a warning for the expression
a < b < c
would seem a good thing, if not exactly high priority.
Most people with any substantial computing experience would probably
realize that what they meant to say was
a < b & b < c
If it wasn't and they wanted the warning message to shut up, they would
need to write
as.numeric( a< b) < c
Yes, we probably should have been less fond of "cute" programming tricks
like the example. In our defense, though, sometimes they helped people
to program in "whole object" terms, particularly in the days when
interfacing to C and other languages was less flexible.
John
-- John M. Chambers jmc@bell-labs.com Bell Labs, Lucent Technologies office: (908)582-2681 700 Mountain Avenue, Room 2C-282 fax: (908)582-3340 Murray Hill, NJ 07974 web: http://www.cs.bell-labs.com/~jmc -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
This archive was generated by hypermail 2.1.3 : Wed 10 Mar 2004 - 08:18:19 EST