According to the “Module-initialization-and-precompilation” section of the manual. “if you define a function __init__()
in a module, then Julia will call __init__()
immediately after the module is loaded”.
Consider the following code:
module A
module B
export b
const b = Ref{Int}(1)
__init__() = (b[] = 2; println("B, b[] = ", b[]))
end
using A.B
__init__() = println("A, b[] = ", b[])
@show b[]
end
I expected B. __init__()
to be called right after the module B .. end
block is processed and the following A
module definitions to see b = 2
, but when I run the above, I get
b[] = 1
B, b[] = 2
A, b[] = 2
Is this expected?