Skip to content
Prev 43187 / 63424 Next

delayedAssign changing values

It is really strange that the delayedAssign is evaluated in the environment
it is called from, and thus can have side effects.
so
x=2
y=3
delayedAssign("x", {y <- 7; y+3}) 

gives
[1] 10
[1] 7

Both x and y changed.
More intuitive would have been the behavior
x=2
y=3
delayedAssign("x", local({y <- 7; y+3}) )
[1] 10
[1] 3
which only changes x.
Or, at least that should be the default behavior....

Michael

--
View this message in context: http://r.789695.n4.nabble.com/delayedAssign-changing-values-tp4588108p4590242.html
Sent from the R devel mailing list archive at Nabble.com.