From murdoch at stats.uwo.ca  Fri Mar 11 13:39:38 2005
From: murdoch at stats.uwo.ca (Duncan Murdoch)
Date: Fri Mar 11 13:39:40 2005
Subject: [Rd] Quirk with as.function(..., envir = NULL) and body(...,
	envir = NULL) <-
Message-ID: <kr3331peistth8hom70kdun6gsm99o5uuk@4ax.com>

I've been doing some looking through the environment code lately, and
noticed that both as.function(..., envir = NULL) and body(..., envir =
NULL)<- treat the NULL as .GlobalEnv, even though NULL is the
environment of the base package.

The code that does this is very deep in the guts of R and affects all
sorts of things, so I'm not planning to change it for 2.1.0, but I
expect it will be fixed in 2.2.0 this fall.

In the meantime, I'd advise people to avoid using envir = NULL, and
instead use envir = globalenv() or envir = .GlobalEnv (which are
equivalent).  

If you want to set base as the environment for a function, you should
use

environment(f) <- NULL

for now. 

Duncan Murdoch


[Rd] Quirk with as.function(..., envir = NULL) and body(..., envir = NULL) <-
Duncan Murdoch