[Rd] attach behavior

Peter Dalgaard p.dalgaard at biostat.ku.dk
Sun Aug 29 09:26:08 CEST 2004

Prof Brian D Ripley <ripley at stats.ox.ac.uk> writes:

> On Sun, 29 Aug 2004, Erich Neuwirth wrote:
> > 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?
> 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().

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!

   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907

More information about the R-devel mailing list