Remove package from environment in Julia

Perhaps you may want to import only the functions that you will be using:

using MyPackage: function1, function2

I’m not sure if this will work for you here as I’m not sure if using brings the whole package into the current environment and therefore using X: f1 will bring the required auxiliary functions along with it in order to make f1 work.

I must say, however, that explicit namespace uses such as Optim.optim is not something you should be avoiding. Even in R, you can use double colon :: to do the same as there are some packages that re-export the same function names. Overall it adds to clarity of your code as you know exactly which version of a function is being called.

5 Likes