I have a tiny file defining a module:
module A
using Dates: now
println("Module $(@__MODULE__) defined at $(now())")
end
If I do Julia: Execute File three times, the REPL output is like so:
Module Main.A defined at 2020-11-11T07:32:24.427
Main.A
WARNING: replacing module A.
Module Main.A.A defined at 2020-11-11T07:32:30.564
Main.A.A
WARNING: replacing module A.
Module Main.A.A defined at 2020-11-11T07:35:32.017
Main.A.A
I find this really confusing! Several questions:
- On the second execution of the file, why is module
Main.A.Adefined, rather thanMain.Are-defined? - Given that
Main.A.Ais defined, why is there also a warning about replacing moduleA? Isn’tMain.Aleft intact? - Why does the third execution of the file not define
Main.A.A.A?
Very frequently I’ll execute a file which defines module A, do some interactive work in the REPL, modify the file, re-execute, and find that for continued REPL work with the updated file, I actually need A_for_real = Main.A.A. Which always surprises me, would love to learn why this happens.