hadley/devtools — pull request #126 by wch (2012-08-04 00:16:13+00:00)
Title: Support for namespace and package environments

This is a first attempt at loading the package into a namespace. It works, but the code seriously needs to be cleaned up.

* The namespace is something like ``
* Everything is loaded into it
* It is a _child_ environment of R_GlobalEnv
* All the objects in the package are loaded in the namespace
* I added a name attribute, but "normal" package namespaces don't seem to have this.

There is also a *package environment*.

* The package environment is something like ``
* All of the objects from the _namespace_ are copied to the package environment. Ideally, this should only copy over exported objects.
* The package environment is a _parent_ of R_GlobalEnv. This is what makes it possible to call functions in the package: first R searches in the global env, then when it doesn't find anything, it searches parent environments.
* The parent environment of the objects is still the _namespace_, even when they're found in the package environment. This what makes it possible for a function to use an internal function which is present in the namespace but not in the package environment.

This is really rough and there will probably be problems unloading namespaces.