Update a const defined in a module

WalterMadelim
Tue, 10 Feb 2026 00:51:34 +0000
General Usage

Now we can update a const

julia> const m = 0
0

julia> const m = 1
1

in a REPL.

But in a larger project I may want to wrap all the consts in another module M.

# Opening a new julia REPL
julia> module M
           const m = 0
       end;

julia> import .M: m

julia> m
0

julia> module M # redefine
           const m = 1
       end;

julia> import .M: m # update
WARNING: ignoring conflicting import of M.m into Main

julia> m # update fails
0

.
I wonder if the m should be updated after the second execution of import .M:m?

PS I know that I can use M.m directly, but that’s anything but convenient—that’s not the desired style of usage.

4 posts - 3 participants