[ESS] r-related question: editing NAMESPACEd functions in packages

Vitalie Spinu spinuvit at gmail.com
Sat Nov 19 23:17:04 CET 2011

On 19 November 2011 20:20, Michael Lawrence <lawrence.michael at gene.com> wrote:
>>    >>
>>    >>    o assignInNamespace() has further restrictions on use
>>    >> apart from at      top-level, as its help page has
>>    >> warned.  Expect it to be disabled      from programmatic
>>    >> use in the future.
>>    >>
>> > Bad news, we are running out of options. There is insertSource in
>> >     > "methods" package which is intended to source all the
>> >     > functions and methods into the namespace. I've implemented
>> >     > the interface to it (bound to C-c C-l and C-M-d s when
>> >     > ess-developer is active), but insertSource is not
>> > working.
>> Hmm, but I had mentioned my own method of working here, namely
>>     attach(asNamespace(..))
>> and putting the changed objects into globalEnv().
> Initially, I was excited about this idea, because the developer-mode would
> not handle e.g. setMethod() calls. The problem though is that attaching the
> namespace does not attach any imported namespaces.

Probably I am missing  something but how exactly
attach(asNamespace(.)) solves the problem? The functions in the
attached namespace cannot see the objects in .GlobalEnv the same way
how functions in namespaces attached by library cannot see those.

I am also sort of missing a real life example. My own packages are
simple enough so that I can just source the files in R_GlobalEnv and
do my changes. Developer mode was just for convenience. When  I would
like to modify a small detail I would just do it in the attached
package. What others would like to use it for? It also would be nice
to clarify what we actually want before pushing it on R-devel.


More information about the ESS-help mailing list