Skip to content
Prev 581 / 21307 Next

[Bioc-devel] Depending vs. Importing?

Florian Hahne <f.hahne at dkfz-heidelberg.de> writes:
Well, that isn't just your "opinion" :-)

When a package Foo lists package Bar in Depends, Bar is loaded _and_ attached to
the search path before Foo is loaded and attached when the user calls
library("Foo").

Importing provides a more fine grained way of handling dependencies
between packages, but the implementation leaves something to be
desired.  To import functionality, a developer must list a package in
Imports _and_ include appropriate directives in the NAMESPACE file.
It makes no sense to use the Imports field if your package does not
have a NAMESPACE.

The main difference with importing is as Florian said: imported
packages are loaded but _not_ attached to the search path.  This keeps
the symbols available from the global env cleaner and makes it
possible to work with packages that have symbol conflicts.

The thing that is confusing and IMO could use improvement is that a
developer must provide the import information in two places, the
Imports field in the DESCRIPTION file and various import directives in
the NAMESPACE file.

I'm not certain, but I think the only places where the Imports field
gets used are during 'R CMD check' and when using the
install.packages() family of functions where the Imports field is used
to track down dependencies.
I think what you mean is that R CMD INSTALL ignores the Imports
field.  Yes, that seems to be the case, but note that it also is the
case for the Depends field; R is perfectly happy to let you install a
package that will not work for lack of dependencies.  This isn't
necessarily a bad thing; it makes installing a collection of packages
easier because you don't have to get the order right.
Not sure what you mean about not being honored.  More detail?

Best,

+ seth