Skip to content
Prev 60 / 63424 Next

R-alpha: lazy evaluation and plot.step()

The explanation seems to be in different behaviour of the
substitute(...) construction:

R:
[1] "c(1, b)"

Splus:
[1] "c(a, b)"
[1] "c(a, b)"

So in R, assignment to a formal parameter causes the changed value to
be used for substitution purposes.

In S, this does not happen *unless the formal parameter is a
constant.*!
[1] "c(1, b)"
[1] "c(1, b)"
[1] "c(2:2, b)"
[1] "c(2:2, b)"
[1] "c(1, b)"
[1] "c(1, b)"

This is confusing in both languages, but I'd say that S has the bigger
problem...

In Kurts example, inserting 

xlab 
ylab

as the first two lines of the function defeats lazy evaluation and
provides the desired behaviour (I suppose) in both R and S.

	- Peter

----

Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at> writes: