Skip to content
Prev 669 / 12125 Next

[R-pkg-devel] double colon

On 29/01/2016 10:56 AM, Uwe Ligges wrote:
I'd add one caveat here:  if you explicitly import things by name, this 
is definitely true.

If you import everything from another package, then conceivably you 
could end up with problems:  e.g. you import all of package A and all of 
package B.  You want Fn from B, and since A doesn't have a function like 
that, you're fine.  But later if package A adds a function called Fn,  
you might get in trouble and end up using the wrong one.

So use

importFrom(A, something)
importFrom(B, Fn)

rather than

import(A, B)

Duncan Murdoch
I think Berry was referring to the case where package Foo has function 
Fn, and was asking whether he should use Foo::Fn within the code of 
package Foo.  The answer to that is no.  Your own locally defined 
functions generally have precedence over ones from other packages 
(unless you mess around with environments; don't do that).