Skip to content

Follow-up: pos= in library and require

4 messages · Brian Ripley, Luke Tierney, Frank E Harrell Jr

#
Unfortunately I found that adding pos= in the attach( ) inside library( ) results in a corruption of the search list.  Packages will be attached in the desired position but the system then can't find any objects in that position.  I would really appreciate R correctly implementing pos= in library( ) and require( ).  

Frank
#
On Sat, 13 Apr 2002, Frank E Harrell Jr wrote:

            
As you know (I hope) R 1.5.0 is currently in feature freeze.
We've had a request to do this before, and we will look into it for 1.6.x.

One issue that occurred to me was what one should do about calls to
library() or require() from the .First.lib (or on loading the code) of a
package if a pos argument is allowed.  Are the dependent packages supposed
to displace the first package or not?  What if the dependent packages are
themselves given a pos= argument (as I think you wanted)?

I prefer to do tricky things early in the release cycle, to allow plenty
of experience with them.  Time has shown that few changes are
transparently simple.
#
On Sat, Apr 13, 2002 at 02:01:01PM +0100, ripley at stats.ox.ac.uk wrote:
I agree.  And the more I think about trying to do this at the
library/require level the more nervous I get--because of the dynamic
nature of the search path I worry that it will lead to all sorts of
nasty litle bugs.  Hopefully I will be able to put a first pass at
name spaces into R-devel very soon after 1.5 is released, which should
give us a significant period to exercise it before 1.6 is released. I
think it would be better to try to use that approach to manage this
sort of thing and only resort to changing library/require if for some
reason name spaces prove inadequate.  I am actually fairly hopeful
that name spaces will allow us to deprecate require before too long,

luke
#
On Sat, 13 Apr 2002 14:01:01 +0100 (BST)
ripley at stats.ox.ac.uk wrote:

            
That's a good question.  But there needs to be some kind of simple way to make require or library attach at the end of the search list instead of position 2, i.e., to get S-Plus's behavior.

A safe approach for now is to instruct users to put library() commands in .Rprofile for dependent packages that we do not wish to override others.  They will be put high in the search path when R starts, and then will move down the list.
Yes, that makes complete sense.  Thanks -Frank