Hi Julia developers, I am not sure where I should post this, so here goes...
I am really impressed with the Julia language. It does many things well. But there is one aspect of C++ that I miss dearly: C++ provides "using namespace X" to "make available" the contents of X to the current scope. This even works on un-named scopes within a function: - See https://github.com/ma-laforge/testcases/blob/master/namespace_test/namespace_test.jl In Julia, the closest functional equivalent appears to be the "using" directive. However, my experiments show that "using" really only works at the module-level: - See https://github.com/ma-laforge/testcases/blob/master/namespace_test/namespace_test.cpp Admittedly, the overall module system in Julia is superior to C++ namespaces. I simply wish the using directive could be applied to arbitrary scopes. Scope-level "using" directives are particularly useful when the multi-dispatch system cannot resolve ambiguities. For example, an "Imperial" module might provide "c" in feet/s. *Effect on coding style* Without scope-level "using" directives, it seems impractical to rely on module hierarchy to limit the name length of "factory" elements (those unresolvable by Julia's multi-dispatch system): - See https://github.com/ma-laforge/testcases/blob/master/namespace_test/arm_objects.jl In C++, it is very natural and easy to use compact names for these factory elements (ex: classes/constructors/constants...): - See https://github.com/ma-laforge/testcases/blob/master/namespace_test/arm_objects.cpp *Questions* 1. Is there a subtlety of Julia's use model that I might be misunderstanding here? 2. If not: would it be feasible to implement scope-level "using" in Julia? *Note* I did notice others out there posting issues regarding namespaces and clobbering. One that stands out right now is a post by Edmund: - https://groups.google.com/d/msg/julia-users/T5YYKQzl-Cc/oJVwnMz9zroJ It appears these posts have died down lately. Indeed, Julia's current module system does provide reasonably adequate options. I just wanted to suggest a way to improve it slightly.
