How to access global variables within a module?

hello, maybe a stupid one, but I failed to find relevant documents…

I have something defined in REPL (with const), but they’re not accessible within the functions defined within a module. What should I do?

thanks.

julia> const a = 1
1

julia> module A
           using ..Main: a
           println(a)
       end
1
Main.A
1 Like

Pass the variables as arguments to the functions.

3 Likes

wow… where is any documentation about ..Main ???

https://docs.julialang.org/en/v1/manual/modules/index.html#Standard-modules-1

https://docs.julialang.org/en/v0.6.0/manual/modules/#Relative-and-absolute-module-paths-1

2 Likes

oh, it’s about “relative module path”.

so, in your first example, why need .. before Main ?

I mean, when we use using inside a module, normally we don’t need that .., and it would automatically search “outside”, right?

You don’t need the .. before Main. I just tried it.

thx