Re: [Rd] Trying to understand the search path and namespaces

From: Hadley Wickham <>
Date: Tue, 16 Nov 2010 07:35:09 -0600

>> Ah, my mistake was assuming that the package namespace and environment
>> were the same thing.
>> Interestingly the namespace is dynamic:
> Not sure what you mean with this.  Section 1.6 of "Writing R
> Extensions" explicitly states:
>        Name spaces are @emph{sealed} once they are loaded.  Sealing
>        means that imports and exports cannot be changed and that
>        internal variable bindings cannot be changed.

Well, if we're going to pick nits, I meant that the parents of the environment are dynamic.

>> > parents(getNamespace("devtools"))
>> ...
>> [31] "base"
>> > library(roxygen)
>> > parents(getNamespace("devtools"))
>> ...
>> [31] "Autoloads"            "base"
> Well, as the part of "Writing R Extensions" that Martin quoted states,
> the normal search path is part of the search path used by packages with
> name spaces.  So if you attach another package via library(), the
> normal search path changes and, hence,
> `parents(getNamespace("devtools"))' has one more location to report.

It's still not at all obvious how this happens - when does variable look up use the stack of environments given by the package environment and when does it use the stack of environments given by the namespace?


Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University

______________________________________________ mailing list
Received on Tue 16 Nov 2010 - 13:40:28 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 16 Nov 2010 - 14:50:22 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive