Skip to content
Prev 39757 / 63424 Next

question about assignment warnings for replacement methods

Hi Simon,
On 11-04-08 01:05 PM, Simon Urbanek wrote:
I tried to lower the chance of getting a comment like this by saying
"the 2 *assignment* operators are equivalent" but apparently I
failed :-/

Seems to me that the places where I can't replace <- by = are exactly
the places where I would be replacing an assignment operator by
something that is not an assignment operator anymore.
I agree with you. I like to be able to directly copy/paste

   a <- foo()

into

   system.time(... paste it here ...)

and press <return> and have it work. But as you said, opinions may
vary...

Anyway, if 'R CMD check' wants to encourage good practice, fine with
me, but then the warning for 'replacementMethod(object) = newValue'
should be something else and also maybe for consistency the code in
the examples and in the vignette should be checked to detect when =
is used instead of <-

Otherwise, 'R CMD check' should just treat

   replacementMethod(object) = newValue

the same way it treats

   replacementMethod(object) <- newValue

Thanks,
H.