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

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Fri 11 Mar 2005 - 12:39:38 GMT


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



R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon Mar 14 10:32:49 2005

This archive was generated by hypermail 2.1.8 : Mon 24 Oct 2005 - 22:26:27 GMT