Ueli Hofstetter
Ueli Hofstetter

Reputation: 2534

Is ":::" an operator?

I am looking through some R Code. Some environments are defined as

"PackageName":::."EnvironmentName" 

What I don't get is what exactly ::: and . are for? Is using ::: just a convention or some kind of scoping operator? Futhermore, what does the "." stand for?

Thx

Upvotes: 2

Views: 82

Answers (1)

jdharrison
jdharrison

Reputation: 30445

::: is an operator for accessing internal variables in a package namespace. For example

utils:::.addFunctionInfo

accesses the function .addFunctionInfo from the utils package. ::: is an operator and the underlying function is `:::`(pkg, name). It can be called with the arguments "utils", ".addFunctionInfo":

> `:::`("utils", ".addFunctionInfo")
function (...) 
{
    dots <- list(...)
    for (nm in names(dots)) .FunArgEnv[[nm]] <- dots[[nm]]
}
<bytecode: 0x000000002e4240d0>
<environment: namespace:utils>

When the R parser sees utils:::.addFunctionInfo it interpretes it as `:::`("utils", ".addFunctionInfo") You can get help on the operator by using

?`:::`

The dot in this case is just part of the variable name. In unix it is often used to denote a hidden file.

Upvotes: 2

Related Questions