Mark.Bravington@csiro.au
2002-Jul-01 09:13 UTC
Assignment operators (was [R] modifying a vector)
Bill Venables expected howls of protest about deprecation of underscore for assign. Here's my one-and-only howl on this point: (1) I don't like <- as an assignment operator, because it creates an ambiguity with comparisons: I can write "x+1", "x-1", "x<1" but not "x<-1". However, I guess it's a bit much to expect the entire R/S community to do away with "<-" in favour of "_" or Delphi (Pascal) notation ":=", much as it would delight me; so we're stuck with <- I guess. (2) "_" strikes me as completely unambiguous. It means assignment, and that's all it means. For my money, that's more important than aesthetics. Anyway, if you choose a nice colourscheme, the _ doesn't look that bad. Me, I like green. (3) for my remaining bit of money, "=" should not be allowed at all as an assignment operator: S made a mistake but R doesn't have to. "="-as-assignment has to be hedged with all sorts of conditions to prevent ambiguities, and to have an operator which frequently can't be used doesn't seem helpful. Having it "grudgingly available to the cognoscenti" is not all that much better! (4) If deprecation is the first step on the road to removal and to "_" being allowed in unquoted variable names, then that would be tiresome. I have many hundreds of functions spanning thousands of lines of S/R code, filled with "_"s. I really don't want to spend time changing all of them just to solve a non-problem in R. Which is, I should emphasize, a wonderful piece of software. Summary: to lose "_" and gain "=" would be a double whammy with added salt in the wound. cheers Mark Mark Bravington CSIRO (CMIS) PO Box 1538 Castray Esplanade Hobart TAS 7001 phone (61) 3 6232 5118 fax (61) 3 6232 5012 Mark.Bravington@csiro.au -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
ripley@stats.ox.ac.uk
2002-Jul-01 10:23 UTC
Assignment operators (was [R] modifying a vector)
On Mon, 1 Jul 2002 Mark.Bravington@csiro.au wrote:> Bill Venables expected howls of protest about deprecation of underscore for > assign. Here's my one-and-only howl on this point: > > (1) I don't like <- as an assignment operator, because it creates an > ambiguity with comparisons: I can write "x+1", "x-1", "x<1" but not "x<-1". > However, I guess it's a bit much to expect the entire R/S community to do > away with "<-" in favour of "_" or Delphi (Pascal) notation ":=", much as it > would delight me; so we're stuck with <- I guess. > > (2) "_" strikes me as completely unambiguous. It means assignment, and > that's all it means. For my money, that's more important than aesthetics. > Anyway, if you choose a nice colourscheme, the _ doesn't look that bad. Me, > I like green. > > (3) for my remaining bit of money, "=" should not be allowed at all as an > assignment operator: S made a mistake but R doesn't have to. > "="-as-assignment has to be hedged with all sorts of conditions to prevent > ambiguities, and to have an operator which frequently can't be used doesn't > seem helpful. Having it "grudgingly available to the cognoscenti" is not all > that much better! > > (4) If deprecation is the first step on the road to removal and to "_" being > allowed in unquoted variable names, then that would be tiresome. I have many > hundreds of functions spanning thousands of lines of S/R code, filled with > "_"s. I really don't want to spend time changing all of them just to solve a > non-problem in R. Which is, I should emphasize, a wonderful piece of > software.There is a simple solution: use the procedures which have long been described in `Writing R Extensions' to turn your code into properly formatted canonical code. (That turns all left-assignments into `<-', since that is the canonical form.). It may be a non-problem for you, but it was for the original poster in the original thread. -- Brian D. Ripley, ripley@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-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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._