[Rd] legitimate use of :::

Yihui Xie xie at yihui.name
Mon Aug 26 04:53:53 CEST 2013

I know it is really bad, but the so-called good approach can be more
expensive than that, primarily because a package with a NOTE in R CMD
check is likely to be rejected by CRAN, or authors have to justify the
NOTE in the email.

For this particular case, I can imagine at least one case which can be
endless trouble to CRAN: if the package author A has talked to B to
use a hidden function in B's package, and B thinks that function is
relatively stable but does not want to export it; A may go ahead and
use it via :::. Both A and B understand that unexported function well,
then what should A do when submitting the package to CRAN? Should CRAN
continue adding rules for such exceptions?

In other words, "bad" practices almost always have exceptions and edge
cases. Of course, the decision is always in CRAN's hands, and I will
try to respect and follow it as a package author.

Yihui Xie <xieyihui at gmail.com>
Web: http://yihui.name
Department of Statistics, Iowa State University
102 Snedecor Hall, Ames, IA

On Fri, Aug 23, 2013 at 11:05 AM, Duncan Murdoch
<murdoch.duncan at gmail.com> wrote:
> On 13-08-22 11:54 PM, Yihui Xie wrote:
>> Maybe it is not a good idea for R CMD check to check ::: at all, and a
>> warning in R-exts and ?':::' may well be enough. On the other hand, it
>> is just so easy to get around :::, because everybody can see its
>> source code:
> It's a really bad idea to write tricky code to subvert the tests.  If the
> tests are wrong, you can argue for changes (and in this case you did, and
> changes were made), but if you can't give a convincing argument, you should
> follow the good practices that the repository policies enforce.
> Duncan Murdoch
>>> `:::`
>> function (pkg, name)
>> {
>>      pkg <- as.character(substitute(pkg))
>>      name <- as.character(substitute(name))
>>      get(name, envir = asNamespace(pkg), inherits = FALSE)
>> }
>> Then the package authors who really want to take the risk may start
>> another "hide and seek" game, e.g.
>> `%:::%` = function(pkg, fun) get(fun, envir = asNamespace(pkg),
>> inherits = FALSE)
>> 'stats' %:::% 'Pillai'

More information about the R-devel mailing list