rticulate/import

Using library() inside imported module should be an error

torfason opened this issue · 1 comments

If a module loads a package through a library() statement, this allows functions to be defined relying on the package, but then they won't work outside the module, with an error that can be cryptic to users.

This behavior is as documented in the readme (https://import.rticulate.org/), but it seems better to throw an error immediately on the import::from() call if this occurs.

Implementing this seems trivial by checking whether .packages() changes during the sourcing of the module. I expect to prepare a PR shortly that does this. Comments/pros/cons/OK appreciated.

On closer thought, perhaps a warning is enough here ...