Importing package into Main conflicts with an existing identifier

happy to help :slight_smile:

1 Like

This is understandable, but it can feel frustrating to new users and add unnecessary stress. Should “using MyModule” simply act as if you typed “using .MyModule”, if MyModule already existing in Main?

Yes, this is possible. But then you must have a way to distinguish two modules with the same name (e.g one in the environment and another in the parent module). This might be less frequent but introduce exceptions which makes the rule less clear. It is a trade off.

How does typing “using MyModule” multiple times avoid the conflict error? The conflict only occurs if MyModule was first loaded from source; it won’t conflict if loaded from environment.

Using varinfo(imported=true/false), I found that loading module from source, the module is NOT considered as imported, it will show up even with varinfo(imported=false). loading from environment, it IS considered imported, and only shows up with varinfo(imported=true)

I don’t know the internals of using, but in the master branch (maybe already on 1.7.3) the error message is more informative. It suggest you to use the dot if it found a defined module.

1 Like