[Rd] Changes to environments in R-devel

Duncan Murdoch murdoch at stats.uwo.ca
Fri Nov 4 01:55:42 CET 2005

I've just committed some changes to R-devel which affect environments. 

  - using NULL as an environment is now deprecated:  use baseenv() 
instead.  (baseenv() is already available in R 2.2.0, where it returns 
NULL.  For most purposes it retains the same meaning in R-devel.) If you 
do use NULL, it will be converted to baseenv(), and a warning printed. 
For example:

 > f <- function(x) 1
 > environment(f) <- NULL
Warning message:
use of NULL environment is deprecated
 > environment(f)
<environment: base>

There may be some places where I've missed putting the conversion in 
place, and use of NULL will cause an error; please let me know if you 
find any of those.  The intention is that NULL will be usable with 
warnings through to the end of the 2.3.x releases.

  - baseenv() is no longer its own parent.  Its parent is an empty 
environment, available as emptyenv().

  - You can now create your own environment with emptyenv() as its 
parent.  Searches for variables in such an environment will not 
automatically proceed to baseenv(), as searches do in current R releases.

Duncan Murdoch

More information about the R-devel mailing list