Using multiple modules in a single line

Is

using Module1, Module2

equivalent to

using Module1
using Module2

?
Is the order significant in single line version?

short answer, no

1 Like

Less short answer: yes, no.

1 Like

Do you mean that evaluation order in using Module1, Module2 is undetermined? I have a situation where:

using Module1
using Module2

works, but:

using Module2
using Module1

doesn’t. So in my case the single line version can’t be used, right?

I’m not certain, but I would believe that using Module1, Module2 is equivalent to using Module1; using Module2. So with your example, you can verify this assumption: using Module1, Module2 would work whereas using Module2, Module1 wouldn’t. Is that the case?

While relying on the order may not be good practice, I don’t think that that this is documented. I would guess that in practice using will load the modules in order.

Maybe open an issue to clarify the docs?

I submitted an issue Semantics of `using` with multiple modules in the same line. · Issue #36090 · JuliaLang/julia · GitHub. I wanted to make sure I’m not missing something obvious first.

1 Like

It is the case, if order is determined.

You did the right thing — it is best to ask first before opening an issue if you are not sure.