behavior of =

Thomas Lumley tlumley@u.washington.edu
Fri, 8 Nov 2002 08:17:12 -0800 (PST)


On Fri, 8 Nov 2002, Philippe Grosjean wrote:

> Deprecating '_' for assignment in the perspective of reusing it in variables
> names is nice (not just a personal impression bacause it is also common in
> other languages). I am fighting too often with unreadable codes like
> var_value, even without spaces before and after '_'!!!
> Addition of '=' for assignment is nice too (also commonly used in other
> languages), except for this problem with named arguments...! I know this is
> a major change that would require patching all R code, but perhaps a
> solution would be to replace '=' in named arguments with something else,...
> ('_'  for instance.. no, I am kidding!). But perhaps, ':=' would be a nice
> candidate. So:
>
> foo(a=b)  # Assignment of b to a, and a is passed as first argument to
> function foo()
> foo(a:=b) # b is passed to the named argument 'a' of function foo()
>

Not only would this require rewriting essentially every piece of R code
ever written, but even worse, := is used in other languages (and in the
prehistory of R) as an assignment operator so it would be even less clear
than the current situation.

For this transition, unlike disposing of '_', there would be no way to
write code (including simple data analyses) that worked before and after
the change.

You can't get there from here (and I'm not convinced you want to).

	-thomas

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._