Dear Vitalie,

On 11/8/18 2:32 PM, Vitalie Spinu via ESS-help wrote:
There are essentially 3 cases:
Thank you very much for the helpful reply!
   1. `moose` is public (exported) function in your package. This means it is
   present in both namespace and package environments when the package is 
loaded.

   In this case, when you eval moose <- function() ... it goes into both package
   environment and namespace environment of the package.

It appears there are two variants to this case. One case is as you describe where I'm working on a package that I load with devtools::load_all. Another is the case of a package that is installed with devtools::install and then I have some other code I'm working on that is calling routines in the installed package. I naively assumed that i could just C-c C-r the source for an installed function and I would get the new version, at least for the current R session. That doesn't seem to be the case. Perhaps it's the object sealing you mention below.

My workaround is to just not INSTALL (or devtools::install) my packages (note one of my occasional R peeves - using capitalization for disambiguation not for emphasis) and to load_all them. This seems to be working for the moment and has greatly reduced my frustration level!

   3. Final case which (seems to be of main interest to you) when `moose` is a
   new function. Then, due to the fact that R namepsaces are sealed for new
   objects ESS has to do some cheating. It basically inserts a new environment
   between package namespace env and its parent and adds all new objects to that
   environment. You should get NEW[moose] message in the minibuffer.

   With this arrangement all your code will work as if that function exists in
   the actual package environment, but you won't be able to see that object with
   ls.
Is that new environment from the REPL? My workaround here is to type code directly into the file that has the, e.g., new function/variable definition, eval what I need with C-c C-r, e.g., and then delete the code. Not the most convenient, but not horrible.
3. If I can’t do this is there some easy way to build an reinstall an existing R
library without having to call me R process and restart every time I want to
make a simple change to a library function (this is where I find myself now).
Namespaced evaluation should work for R code as described above. If not, it's a
bug.

Ok, it's very helpful to know what the intended/expected behavior us before I go running off thinking something might be a bug.

thanks again!

Cyrus

______________________________________________
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Reply via email to