[R] using ``<-'' in function argument

Ivan Calandra ivan.calandra at uni-hamburg.de
Fri Dec 3 11:57:03 CET 2010



Le 12/3/2010 11:35, Berwin A Turlach a écrit :
> 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" :)
Well you did say it indeed... but it doesn't mean that I understood it, 
I needed more details to grasp it!
>> 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
>

-- 
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calandra at uni-hamburg.de

**********
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php



More information about the R-help mailing list