[Rd] is.environment, as.environment, and NULL
Peter Dalgaard BSA
p.dalgaard@biostat.ku.dk
28 Aug 2001 00:22:54 +0200
John Chambers <jmc@research.bell-labs.com> writes:
> There isn't a completely consistent solution, given the use of NULL as
> an environment. For the moment it seemed best to live with that one
> anomalous result in the tests.
The use of NULL for the base environment is something which I would
like to see go away anyway. It makes little sense semantically (if
anything, you would want the NULL environment to be an empty one), and
there are pitfalls where a NULL value returned by accident can cause
code to work in base but not in a package.
I did start to look into it at some point but ran out of stamina or
got distracted (probably by release timings as usual...). As I recall
it, NULL for base envir is only really used in a handful of places as
a sentinel for searches through the search path, as in:
for (rho = R_GlobalEnv; rho != R_NilValue; rho = ENCLOS(rho)) ..
The base environment is special because the symbol lookups are
different there, but it could be represented by R_BaseEnv or some such
instead of R_NilValue. I doubt that much interpreted code needs to
explicitly test whether an environment is the base environment. One
thing to watch out for might be saved workspaces, though. On the other
hand, we do not save the search path, so maybe not...
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._