[R] using ``<-'' in function argument
Berwin A Turlach
berwin at maths.uwa.edu.au
Fri Dec 3 11:35:32 CET 2010
G'day Ivan,
On Fri, 03 Dec 2010 10:54:58 +0100
Ivan Calandra <ivan.calandra at uni-hamburg.de> wrote:
> Arf, yes it makes sense now!
Well, my original post said: "R has lazy evaluation" and "the
assignment takes place when the function evaluates the argument" :)
> So the idea here is: never use "<-" in function argument...
Never say never. :)
But if you want to perform a (global) assignment within an actual
argument to a function, you should better be sure that the
formal argument gets evaluated. In fact, this trick is probably a good
way, short of studying the source, to find out whether an argument gets
evaluated or not (or only occasionally).
Cheers,
Berwin
More information about the R-help
mailing list