Thank you for the C++ example, I think it’s a helpful way to discuss this problem.
So the main
function would of course live in an implementation (.cpp
) file as opposed to a header file. Now while not everybody in C++ land agrees whether having using
directives in implementation files is a good idea, there really seems to be a consensus that having using
directives in header files is very bad style:
- C++ core guidelines (Stroustrup and Sutter), https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rs-using-directive - “Don’t write using namespace in a header file.”
- GNU, libstdc++ manual, Namespaces - “This approach works well for individual source files, but should not be used in a global context, like header files.”
- Google style guide, Google C++ Style Guide - “Do not use using-directives (e.g. using namespace foo).”
In Julia, there is (thankfully, in my opinion) no distinction between a header file and an implementation file. So in effect, every file is a header file (as well as an implementation file), and thus C++ best practice would have it that use of the Julia equivalent of using namespace
statements should be avoided.
Now that doesn’t necessarily mean that Julia’s using
should currently be avoided if you believe that these C++ best practices are worth adhering to; Julia’s using
is not exactly the same as C++'s using namespace
. But if the type of behavior in your main
function were to happen in Julia code as a result of using MyModule; using MyModule2
, then I would think that this hypothetical version of Julia’s using
is sufficiently similar to C++'s using namespace
for the C++ best practice rule to apply.
Edit: I reread your post more thoroughly, and I think the second example (without the using namespace
statements, i.e. argument-dependent lookup) is actually very interesting though. This may be where there could be some space for Julia to be improved.