Henrik Bengtsson
2012-Mar-09 05:09 UTC
[Rd] .conflicts.OK no longer working regardless of export(.conflicts.OK) due to "stoplist"
Hi,
in (at least) R v2.14.2 and R v2.15.0 alpha, '.conflicts.OK' is not
exported and hence to seen by library().
DETAILS:
In R-devel thread '[Rd] Suggestion: Not having to export .conflicts.OK
in name spaces' on Mar 17-22, 2010
[https://stat.ethz.ch/pipermail/r-devel/2010-March/057017.html] it was
discussed that one had to export '.conflicts.OK' in the namespace,
otherwise it would not be found in the internal conflict test of
library(), cf. print(base::library):
...
if(warn.conflicts &&
!exists(".conflicts.OK", envir = env, inherits
= FALSE))
checkConflicts(package, pkgname, pkgpath,
nogenerics, ns)
...
By replacing envir=env with envir=ns, it will be found. Here is what
I get if I use debug(library):
Browse[2]> exists(".conflicts.OK", envir=env, inherits=FALSE)
[1] FALSE
Browse[2]> exists(".conflicts.OK", envir=ns, inherits=FALSE)
[1] TRUE
This was never implemented, but export(.conflicts.OK) do the job. So
far so good, but in rev 56711 (Aug 12, 2011) the following piece of
code was added to loadNamespace() [src/library/base/R/library.R],
which drops '.conflicts.OK' regardless:
## process exports, seal, and clear on.exit action
exports <- nsInfo$exports
for (p in nsInfo$exportPatterns)
exports <- c(ls(env, pattern = p, all.names = TRUE), exports)
## certain things should never be exported.
if (length(exports)) {
stoplist <- c(".__NAMESPACE__.",
".__S3MethodsTable__.",
".packageName", ".First.lib",
".onLoad",
".onAttach", ".conflicts.OK",
".noGenerics")
exports <- exports[! exports %in% stoplist]
}
To confirm this is the problem one can load the package with
debug(loadNamespace), step through the function and after the above
"stoplist" filtering append '.conflicts.OK', e.g. exports
<-
c(exports, ".conflicts.OK"), and '.conflicts.OK' is yet again
visible
to library().
SOLUTION:
Thus, I propose to do the above 'envir=env' to 'envir=ns' update
in
library() to fix this.
/Henrik
> sessionInfo()
R version 2.14.2 Patched (2012-02-29 r58590)
Platform: x86_64-pc-mingw32/x64 (64-bit)
> sessionInfo()
R version 2.15.0 alpha (2012-03-07 r58630)
Platform: x86_64-pc-mingw32/x64 (64-bit)
Possibly Parallel Threads
- Never exporting .__global__ and .__suppressForeign__?
- Ctrl-C at the Rterm prompt is remembered (unless pressing ENTER).
- Suggestion: Not having to export .conflicts.OK in name spaces
- [New Patch] Fix disk corruption when writing
- loadNamespace and versionChecking and the otherpackage::otherfun syntax
