From hb at stat.berkeley.edu  Fri Aug 24 21:07:50 2007
From: hb at stat.berkeley.edu (Henrik Bengtsson)
Date: Fri, 24 Aug 2007 12:07:50 -0700
Subject: [Rd] Suggestion: Making attach() and detach() generic
Message-ID: <59d7961d0708241207j5f66a6abkca2626455df810c9@mail.gmail.com>

Hi,

I would like to suggest to make base::attach() and base::detach()
generic, in order to attach/detach fields of other containers
("databases") than the currently supported ones.

According to help on attach(), one could dispatch on (first) argument 'what'):

    what: "database".  This may currently be a 'data.frame' or a 'list'
          or a R data file created with 'save' or 'NULL' or an
          environment.  See also Details.

So, in S3 terms, something like:

attach():
 attach.data.frame()
 attach.list()
 attach.environment()
 attach.character()
 attach.default()

detach() could be extended in a similar way.

The first step to make attach()/detach() generic would to justed
rename the current attach() to attach.default() and ditto for
detach().  [I haven't investigated all the side effects of doing this;
there could be problems with substitute():s etc.]

Comments?  I would be happy to do the mods, if wanted.

Cheers

Henrik



[Rd] Suggestion: Making attach() and detach() generic
Henrik Bengtsson