[Rd] is.environment, as.environment, and NULL

John Chambers jmc@research.bell-labs.com
Mon, 27 Aug 2001 17:53:09 -0400


The r-devel (1.4) code has C implementations now of the class and
class<- functions in package methods, and also of as.environment.

The last brings up a question (it shows up in the isas-tests test
suite).

as.environment(NULL) is NULL.  Seems like it has to be, since NULL is
the environment associated with package:base.

But is.environment(NULL) is FALSE, which is also fairly natural, if we
think of testing the type of the argument.

The inconsistency causes a related test in isas-tests.R to produce a
FALSE (where generally they should either evaluate to TRUE or generate
an error).

Looking at the uses of is.environment in the R source itself, most of
them seem to hedge their bets on whether is.environment(NULL) is TRUE or
FALSE.

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.

John
-- 
John M. Chambers                  jmc@bell-labs.com
Bell Labs, Lucent Technologies    office: (908)582-2681
700 Mountain Avenue, Room 2C-282  fax:    (908)582-3340
Murray Hill, NJ  07974            web: http://www.cs.bell-labs.com/~jmc
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._