Has something changed in the way R handles lazy evaluation?

I was wondering if something had changed about how R handles lazy evaluation.

I ask for this after reading Hadley Wickham AdvancedR on ...

On my website (see http://adv-r.had.co.nz/Functions.html ), adders and adders2 give the same result, so I assume something has changed (recently?) In that how R handles lazy evaluation.

The following is a reproducible example of what I mean:

add <- function(x) { function(y) x + y } add2 <- function(x) { force(x) function(y) x + y } adders <- lapply(1:10, add) adders2 <- lapply(1:10, add) adders[[1]](10) adders[[10]](10) adders2[[1]](10) adders2[[10]](10) 

Historically, we expected to get:

 > adders[[1]](10) [1] 20 > adders[[10]](10) [1] 20 > adders2[[1]](10) [1] 11 > adders2[[10]](10) [1] 20 

However, on my computer (and on the Hadley website) the result is:

 > adders[[1]](10) [1] 11 > adders[[10]](10) [1] 20 > adders2[[1]](10) [1] 11 > adders2[[10]](10) [1] 20 

On my computer, R.Version() gives:

 > R.Version() $platform [1] "x86_64-apple-darwin13.4.0" $arch [1] "x86_64" $os [1] "darwin13.4.0" $system [1] "x86_64, darwin13.4.0" $status [1] "" $major [1] "3" $minor [1] "2.0" $year [1] "2015" $month [1] "04" $day [1] "16" $`svn rev` [1] "68180" $language [1] "R" $version.string [1] "R version 3.2.0 (2015-04-16)" $nickname [1] "Full of Ingredients" 
+4
source share

All Articles