Why "using" instead of "use"?

Out of curiosity, when loading a module, why do we use using Foo instead of use Foo? I found this looks inconsistent because we use import Foo instead of importing Foo. Is there any implication here?


A few potential but not very strong reasons:

  • I think it comes from the C-esque “using namespace Foo”.
  • They’re both a similar length… which looks nicer?
  • Using is a very broad operation, basically merging the exported namespace of Foo with your current namespace. In my mind, the present continuous tense conveys this broadness. Now Foo is part of the rest of your code. Your code can look inside it to find names. You are accepting everything that it exports, for better or worse, and you are accepting it forevermore—well, at least until the end of the module.
    On the other hand, import Foo or import Foo.Bar is a more precise action: load in this specific thing under this name, which you can then refer to later. So it feels right, at least to me, that it uses the simple rather than the continuous tense.

Of course, this goes out the window when you can also do using Foo: Bar

1 Like

Yeah, it may come from C++.

All other keywords (import, export, let, try, do, begin, etc.) do not end with “ing”, so I thought there will be some meaning. I hope to see comments from historians of Julia.

1 Like

Is this historical curiosity, or do you propose that it is changed?

I assume there is some good reason to name it as using. But if no reason, I think we should rename it for consistency (hopefully before Julia 1.0).

Certainly not everybody loves the distinction between import and using (for multiple reasons), but I do think the difference in linguistic form is meaningful. import is an imperative action that happens once. It brings in a name up front, and then it’s done. The effect of using happens over time — it says “I will generally be using this package”, with names resolved from it on demand. The C++ precedent contributes as well.


What you say is quite meaningful, thanks for the explanation.

By the way, I wonder what you think of the explicit export from modules (Is an explicit "export" a good thing? - #35 by PetrKryslUCSD)?

Thank you for your reply. That sounds reasonable to me, though I don’t strongly agree with it.