Update a const defined in a module

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.

In a larger project, the recommended workflow is to create a package and use Revise.jl. It works really well, and should (among other benefits) speed up your execution over include-based workfows. using M.m should work fine and be updated automatically if M is a package.

1 Like