Is there any possibility that Julia will have
local import in the future? I’m aware some people think this is a silly idea; however, this would actually solve a very real problem some users might face.
Namely, people want to extend operations like
+,-,*,^, etc on
Expr types, and it would be desirable to have these definitions in a sub-module of a package to make extensions optional. The problem is, any new module that is defined with
import statements extend on a global scope before
Therefore, it would have language applicability if the
import statement could be handled locally, and then optionally extended to the main scope with
using. I’ve been told it isn’t possible with Julia, but I am optimistic. It would require some kind of a table that keeps track of which method extensions are available in what scope. Saying that it is entirely impossible seems rather improbable to me.
Perhaps, having this could speed up the method-look-up in some cases, since there would be fewer extensions to search through in a given scope.
Before you try to shove this issue under the rug, consider that multiple packages that all define arithmetic operations on symbols and expressions cannot be loaded at once because of this issue. However, if
local import where possibe, then different packages that depend on different extensions of the same methods can be used together without interference (because then scope determines the method extension selection).