Disclaimer: I am pushing R to its technical limits here, for fun and profit.
The :: operator is, well, an operator. It's defined as
> `::`
function (pkg, name)
{
pkg <- as.character(substitute(pkg))
name <- as.character(substitute(name))
getExportedValue(pkg, name)
}
Which means that a::b is equivalent to `::`(a, b).
For this reason, a::b::c should be equivalent to `::`(a, `::`(b, c)), or `::`(`::`(a, b), c) depending on precedence rules, exactly as the `+` operator.
Nevertheless, it seems not to work:
> a::b::c
Error: unexpected '::' in "a::b::"
Of course there's a substitute in the middle, which complicates things, but it seems more like a parsing error. I also tried with using parentheses, such as (a::b)::c, but it still does not work.
I don't see why, considering that a::b::c should not be different from a + b + c when it comes to parsing.
Is the :: operator treated differently by the parser? If yes, why?