[Bioc-devel] requireNamespace() / loadNamespace() vs. Imports: / Depends: / Suggests:
Tim Triche, Jr.
tim.triche at gmail.com
Thu Apr 27 19:01:08 CEST 2017
Today I stumbled across requireNamespace() as a suggested approach to
managing sprawling dependencies, particularly in packages that are meant to
be "core" building blocks in e.g. BioC.
http://r-pkgs.had.co.nz/namespace.html
My reading (which may be very, very far off) is that when a desirable piece
of code is "optional" in the sense of "the user can opt not to install
these other 90 packages" but "suggested" in the sense of "it is suggested
that the user bite the bullet anyways", a compromise is to Suggest:
installation and then fail at runtime with a message from
requireNamespace("suggestedPackage") if the suggestion is not heeded. Is
this considered good practice?
Mulling it over, my initial reaction of "hey, that's cheating!" has given
way to "this is a clever way not to overburden users". Am I reading the
underlying logic correctly? I can think of numerous applications for this
approach in packages I have developed, not the least of which is patching
an ancient piece of code that performs a generalized Gamma deconvolution
and once required C++ (hence I ended up commenting out the dependency,
which broke most Windows users' installation of the entire package).
Thanks,
--t
[[alternative HTML version deleted]]
More information about the Bioc-devel
mailing list