Description
In the example below are three (top level) modules, ModA
, Meta
, and ModB
. ModB
attempts to use the other two.
The trouble is that ModB
has an implicit using Base
, which shadows the top level Meta
module:
module ModA
export myvar_A
myvar_A=5
end
module Meta
export myvar_Meta
myvar_Meta=5
end
module ModB
using ModA, Meta
@show myvar_A
@show myvar_Meta
end
Running this in the repl gives me
myvar_A => 5
ERROR: myvar_Meta not defined
This behavior caused me the trouble in toivoh/Debug.jl#35: Debug.jl
has a sub-module Debug.Meta
. When Base.Meta
was added, it shadowed Debug.Meta
for the other Debug
sub-modules. In general, it seems to me that the current behavior with implicit using Base
risks to break existing code each time an export is added to Base
.
My suggestion is to change name lookup within a module according to:
- No implicit
using Base
in any module - If name lookup fails within a non-bare module, a lookup is made in
Base
as a fallback.
An alternative would be to change the interpretation of using
to provide a fallback only if an identifier is not found in any other way.
Activity