In package development, I often find myself needing to bring lots of things into scope, so I can run bits and pieces as if my package were running them. Something like
julia> using Foo # or some package I'm developing
julia> using Foo: f, g, h, j
julia> using Bar # a dependency of `Foo`
It’s a lot of typing, and it’s very error prone. It would be a lot easier if we had a way to change modules from the REPL. Is this possible? Or maybe there’s an easy way to automate what I’m currently doing?
I don’t have an answer to your specific request, but if you only want to run a few isolated expressions, you can use
@eval M expr to tell that you want to evaluate
expr in module
M. Or if it’s a larger piece of code that is written in a file, you can use
Also, since you are telling explicitly that you would like to change the working module in the REPL, I guess that you already know of how to do it in other environments. But anyway, I think that it is worth to comment that in VS Code you can choose the module where each file is meant to be run (also for “inline execution” with Alt+Enter etc.).
Really helpful suggestions, thank you @heliosdrm !
You could also give this Gist a go:
Juno also automatically changes the REPL module to the current module, while VSCode doesn’t (as pointed out above).
This works beautifully! Unfortunately help mode and REPL completion doesn’t see that the module has changed.