I'm interested in the difference between these two intuitively
equivalent sequences that produce different results (in R version
2.13.1 (2011-07-08) 32-bit). I think R's reference counting
optimization is causing this difference in behavior.

> a <- 1
> a+{a[1] <- 20}
[1] 21

> a <- 1
> a[1] <- 1
> a+{a[1] <- 20}
[1] 40

Is one of these the "correct" answer, or is the order of side effects
undefined in these statements? Section 4.3.3 of the R Language
Definition just says that doing assignment in an argument to a
function is "bad style", but doesn't say anything about evaluation
order.

In general, for primitive and internal functions, is a particular
evaluation order for the arguments guaranteed?

Thanks,
Justin Talbot

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to