On Fri, 15 Jan 2010, Barry Rowlingson wrote:

On Fri, Jan 15, 2010 at 6:57 AM, Ted Harding
<ted.hard...@manchester.ac.uk>wrote:


There is at least one context where the distinction must be
preserved. Example:

 pnorm(1.5)
 # [1] 0.9331928
 pnorm(x=1.5)
 # Error in pnorm(x = 1.5) : unused argument(s) (x = 1.5)
 pnorm(x<-1.5)
 # [1] 0.9331928
 x
 # [1] 1.5

Ted.


I would regard modifying a variable within the parameters of a function
call as pretty tasteless. What does:


foo(x<-2,x)
or
foo(x,x<-3)

do that couldn't be done clearer with two lines of code?


It allows the lazy evaluation mechanism to determine whether the  assignment 
happens. That would be very hard to do in two lines of code.

        -thomas

Thomas Lumley                   Assoc. Professor, Biostatistics
tlum...@u.washington.edu        University of Washington, Seattle

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to