[R-SIG-Mac] A shorthand for '<-'
Herve Pages
hpages at fhcrc.org
Thu Nov 22 00:27:29 CET 2007
Hi,
John Chambers wrote:
[...]
> In a sense "=" inside a function call is not semantically an operator at
> all; it's absorbed by the parser into the internal structure that
> represents the call. In contrast, putting an assignment operator inside
> an argument to a function is very different (and, IMO, something to be
> avoided in writing clear S-language code.)
Not only in S or R. I would say this should be avoided in any language
where the order in which the function args are evaluated is undetermined,
especially in situations like this one:
b <- 0
f(a <- b + 1, b <- 7) # will call f(1, 7) or f(8, 7)?
[...]
> Again, the parser prohibition comes from catching a classic programming
> error in C (and another complaint about using "=" as an assignment
> operator).
>
> while(flag = 0) { // of course, I meant (flag == 0)
> ...
> if(something(...)) flag = 1;
> }
>
> after which the programmer wonders why the loop never exits.
You mean, the loop will never enter.
Cheers,
H.
More information about the R-SIG-Mac
mailing list