[Rd] R Language Manual: possible error
Ross Boylan
ross at biostat.ucsf.edu
Fri Feb 16 22:36:57 CET 2007
The R Language manual, section 4.3.4 ("Scope"), has
f <- function(x) {
y <- 10
g <- function(x) x + y
return(g)
}
h <- f()
h(3)
... When `h(3)' is evaluated we see that its body is that of `g'.
Within that body `x' and `y' are unbound.
Is that last sentence right? It looks to me as if x is a bound
variable, and the definitions given in the elided material seem to say
so too. I guess there is hidden, outer, x that is unbound. Maybe the
example was meant to be
g <- function(a) a + y?
The front page of the manual says
The current version of this document is 2.4.0 (2006-11-25) DRAFT.
--
Ross Boylan wk: (415) 514-8146
185 Berry St #5700 ross at biostat.ucsf.edu
Dept of Epidemiology and Biostatistics fax: (415) 514-8150
University of California, San Francisco
San Francisco, CA 94107-1739 hm: (415) 550-1062
More information about the R-devel
mailing list