What's the difference between box:: and import::?
#315
-
|
See https://cran.r-project.org/web/packages/import/vignettes/import.html. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Iβve been meaning to write a comparison article but doing this in a fair way is hard because (a) I am obviously biased and (b) I admittedly donβt know βimportβ nearly as well as βboxβ. Having said that, it is my conviction that the module system implemented by βboxβ is strictly superior to that implemented by βimportβ. Furthermore, as far as I am aware, the functionality provided by βboxβ is a superset of the functionality provided by βimportβ: it does everything1 βimportβ does, plus more. But letβs start at the beginning. βboxβ and βimportβ have a large overlap in functionality and aim to solve some of the same problems, but I think the overarching aims differ:
Over time, the two packages have converged in functionality. In particular, βimportβ has gained the ability to load code from scripts rather than packages, which is similar to (but more limited in scope than) the module system from βboxβ. And βboxβ has gained the ability to import packages in addition to modules because I realised that my stated aim of replacing the existing package system was too ambitious. So what does βboxβ provide that βimportβ does not provide?
(Note that this is a non-exhaustive list; I do want to keep it short.) Here they are in more detail: Global module libraryβboxβ knows two types of modules: project-local modules and global modules. Project-local modules are located in a subfolder of the current project. Global modules are located in one or more a central installation locations, akin to the R package library (thatβs why you can use an R package in your code without having to reinstall it for each project). The R package library paths are configured via Relative imports that actually workSupporting project-local modules β and in particular hierarchical, nested modules β requires that these modules can be found by the import mechanism. βboxβ does a lot of work behind the scenes to ensure that First, here is the folder structure: And here is the (working) βboxβ implementation:
|
Beta Was this translation helpful? Give feedback.
Iβve been meaning to write a comparison article but doing this in a fair way is hard because (a) I am obviously biased and (b) I admittedly donβt know βimportβ nearly as well as βboxβ. Having said that, it is my conviction that the module system implemented by βboxβ is strictly superior to that implemented by βimportβ. Furthermore, as far as I am aware, the functionality provided by βboxβ is a superset of the functionality provided by βimportβ: it does everything1 βimportβ does, plus more.
But letβs start at the beginning. βboxβ and βimportβ have a large overlap in functionality and aim to solve some of the same problems, but I think the overarching aims differ:
The primary aim of βimpoβ¦