Closed banbh closed 7 years ago
Hi, thanks for using the package! I hope it helps.
What exactly do you mean by searchpath? A similar concept like the search path in R (aka search()
) or that a module is loaded relative to the location of the parent module (getwd()
and setwd()
). Assuming you are interested in the latter, it is currently not possible. I did not implement it, because I think within the R ecosystem this behavior would be rather unexpected. Although I can see the benefits of having a system like that - as far as I know that is how Python modules work.
The idea for the usage is that the main script loads dependencies and knows where to find them. A module should assume that its root is the project root. When a module loads other modules and I worry if they can always find each other I would pick among the following options:
use("folderName")
.The forth route is to implement the feature you are looking for. However this is not easy since it was nothing I had in mind while I implemented the package. Ah, and by the way, there is another package called modules which I reference in the Readme. You can have a look if that behavior is more to your liking. I think, at least in the beginning, the development was heavily influenced by Pythons modules.
When you compared what I was asking about with Python modules you hit the nail on the head. Thank you for the detailed answer and for explaining your philosophy (and alternatives).
When treating a script as a module, and loading via
use(fileName)
(as described in the README), is it possible to have a searchpath defined? The goal would be to be able to executeuse("my_lib")
(oruse("my_lib.R")
) and have a module loaded from a central location (rather than the current working directory).