Combine using M: a, b; import M

Now that

using M: a, b

does not import M per se, I found that I have to add an import explicitly when I am being very tidy with namespaces in packages (just using what I use frequently, qualify the rest).

Is it possible to combine these two in a single line?

using M: a, b, M

appears to work.

I wonder it this is accidental, or something I can rely on. I am inclined to the latter, since here I am using M as a symbol, not as a module designator (which would require using M.Submodule).


Nice trick, which should always work as there is always a self-reference.

1 Like

Thank you! I was facing a warning in 0.7 with that so concluded it was not valid, and hadn’t thought it could be ok on 1.0.

Yes, this will keep working (unless we remove the module “self reference”, which some people want, but I don’t think is likely). There was a warning in 0.7 because using M: M used to be equivalent to using M, but now will just bring in a single binding for M itself rather than everything exported from it.


Nice, I didn’t know about this. This was my only use-case for import, but now I can replace all my import M with using M: M and not need import at all.

:fireworks: :fireworks: