[Bioc-devel] Depending vs. Importing?
Seth Falcon
sfalcon at fhcrc.org
Mon Jul 10 18:38:43 CEST 2006
Florian Hahne <f.hahne at dkfz-heidelberg.de> writes:
> IMO, the only difference is that the package is not attached on package
> load time for imports, so one can reduce the overhead for packages with
> a lot of minor dependencies.
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.
> Until now I haven't realized that the information in the imports
> field is not evaluated during package installation (is this really
> the case?).
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.
> Byron Ellis wrote:
>> Is there any particular reason Imports and different from
>> Dependencies? I may be missing something, but importing would seem to
>> imply a dependence relationship which doesn't appear to be honored.
>> rflowcyt (not to pick on it, it just happened to be the package I
>> tried to load) for example imports but does not depend on prada.
Not sure what you mean about not being honored. More detail?
Best,
+ seth
More information about the Bioc-devel
mailing list