[R] Question on closure (lexical scoping) and encapsulation
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Wed Jun 14 19:35:21 CEST 2000
murdoch at stats.uwo.ca (Duncan Murdoch) writes:
> Shouldn't the line "attributes(x) _ NULL" have applied only to x, the
> local copy of .GlobalEnv?
I don't think so. There is only one .GlobalEnv. Environments are not
copied on assignment (or everything else breaks!).
Think of "$<-.foo" <- function(e,name,value) assign(name,value,envir=e)
Would you have expected the assignment to go in the local copy too?
It does have unforseen side effects though:
> class(.GlobalEnv)<-"foo"
> class(.GlobalEnv)
[1] "foo"
> unclass(.GlobalEnv)
<environment: R_GlobalEnv>
> class(.GlobalEnv)
NULL
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list