Skip to content

attach behavior

3 messages · Erich Neuwirth, Brian Ripley, Peter Dalgaard

#
In R 1.9.1, attaching an object more than once puts the object's name on 
the search path more than once also. Therefore, to remove it, one has to 
detach it multiply.
Wouldn'tn it make sense to change the behavior of attach in a way
that object names are not added to the search path more than once?
#
On Sun, 29 Aug 2004, Erich Neuwirth wrote:

            
They need not be the same object, so no.  It's quite common practice to
modify an object, attach it temporarily and detach it again.  I suspect
that people using attach() frequently should be thinking more in terms of
with().
#
Prof Brian D Ripley <ripley@stats.ox.ac.uk> writes:
That's one argument. Another is that attach(foo) followed by detach()
should leave the search path unchanged. I.e. if attach() is sometimes
a NOP, we must arrange so that the next detach() is one too. You could
do that I suppose, but then there's code that acts depending on what
it finds in search(), and... 

Or, briefly: That way lies madness!