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

Vitalie Spinu spinuvit at gmail.com
Sun Nov 20 14:44:39 CET 2011


>
> 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.
>
To make the attach(asNamespace(.))  work, one would have to change the
environment of all functions in attached namespace to .GlobalEnv and
attach the package imports, to make sure .GlobalEnv has precedence and
imports are visible as well. Messy stuff :(

Methods apparently behave differently. If you redefine a method from
attached namespace in .GlobalEnv,  functions from namespace will use
the method from .GlobalEnv and not the one in the namespace. Looks
like attach(asNamespace(.)) is a  way to go for S4 development at
least.

> 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.
>
> Vitalie.
>



More information about the ESS-help mailing list