On Fri, Jan 6, 2012 at 11:13 PM, R. Michael Weylandt <michael.weyla...@gmail.com> wrote: > Presumably because the i <= 4 has to be re-evaluated at the start of > each iteration of the while-loop which implicitly force()s it? > > Though, I don't know if it might not be a bad idea to put an implicit > force() in the internal code for `for` to prevent these sorts of > things. I can't immediately think of a scenario where this sort of > behavior would be useful. It might also simplify the internals to pass > a value rather than what I presume is actually a promise (but I > haven't looked yet and I'm still not in a position to verify)
It does not appear to be a promise. Using a C routine that returns TRUE for a promise and FALSE otherwise: > # test ispromise > > # is a promise > delayedAssign("a", x+1) > .Call("ispromise", "a", .GlobalEnv) [1] TRUE > > # not a promise > xx <- 3 > .Call("ispromise", "xx", .GlobalEnv) [1] FALSE > > # seems index of for is not a promise > # > for(i in 1:3) print(.Call("ispromise", "i", .GlobalEnv)) [1] FALSE [1] FALSE [1] FALSE -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.