[R] combining mathematical notation and value substitution
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Fri Jun 27 09:38:08 CEST 2003
Thomas Lumley <tlumley at u.washington.edu> writes:
> While the rules for constructing the tree are part of the language
> definition, the order of evaluation might not be. In C, for example, the
> order of evaluation is not specified except to the extent that precedence
> constrains it (and for a few special operators like && and ||).
>
> FOr an R example, if you do
> f(plot(a), plot(b))
>
> it is clear that the plot commands must be evaluated before f() returns if
> their return values are actually used. It is not clear which order the
> plots() appear, and I would say that it shouldn't be part of the language
> definition.
...not to mention that lazy evaluation explicitly makes the order dependent
on the function body:
f <- function(x,y) {x;y}
f <- function(x,y) {y;x}
will produce the plots in different order when called as above. Notice
in particular that constructs like
f(a<-b, a)
are playing with fire, unless you're really, really sure that the 1st
arg is evaluated before the 2nd.
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list