[R] Question on closure (lexical scoping) and encapsulation
murdoch at stats.uwo.ca
Wed Jun 14 19:10:17 CEST 2000
I was playing with Peter's suggestion in 1.0.1 and came up with
something that might be a bug. Opinions?
I wanted a slightly fancier version of the environment printer: it
should label what it's printing as an environment. But I don't want
the ugly class attribute to show, so I came up with this:
attributes(x) _ NULL
Before I set the class, I see this:
Now I set the class, and my new print method is activated. Looks just
the way I wanted:
> class(.GlobalEnv) _ 'foo'
 "d" "print.foo" "ranges" "variances" "x" "y"
However, it only works once, because I've lost the attributes from
.GlobalEnv, not just from my local copy of it:
Shouldn't the line "attributes(x) _ NULL" have applied only to x, the
local copy of .GlobalEnv?
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