Say I have a package A
with the following:
module A
const foo = Dict(1 => 'a')
end
and I want to alias foo
in a dependent package B
module B
using A
const foo = A.foo
end
if A.foo
is then updated (e.g. via A.foo[2] = 'b'
) I find that B.foo
holds the value of A.foo
at (pre?)compile time, which is not what I want. Is there a way that B.foo
can simply be an alias for A.foo
?
do you want to reexport A.foo
for users of B
..?
wait, how are you observing that change?
if you have
module C
using A
using B
end
then the A.foo
in C
_should_ be different from the A.foo
in B
, I think
regardless, this works:
julia> module A
const foo = Dict(1 => 'a')
end
Main.A
julia> module B
using ..A: foo
end
Main.B
julia> module C
using ..A
using ..B
f() = @show A.foo === B.foo
end
Main.C
julia> using .C
julia> C.f()
A.foo === B.foo = true
true
Last updated: Nov 22 2024 at 04:41 UTC