Exported functions do not update

I am using the REPL workflow described in REPL Workflow.

Suppose the contents of Tmp.jl are as follows:

module Tmp
export say_hello

say_hello() = println("Hello!")

# your other definitions here

end

And the contents of tst.jl are:

include("Tmp.jl")
#import .Tmp
using .Tmp # we can use `using` to bring the exported symbols in `Tmp` into our namespace

#Tmp.say_hello()
say_hello()

# your other test code here

Now if I edit the say_hello() function and do include('tst.jl') the function definition is not updated in REPL. This problem goes away if I call the function as Tmp.say_hello(). Is this the expected behaviour?

2 Likes

I think that’s expected. Here’s what I get when I run the test script after having modified say_hello:

julia> include("Tst.jl")
Hello!

julia> include("Tst.jl")
WARNING: replacing module Tmp.
WARNING: using Tmp.say_hello in module Main conflicts with an existing identifier.
Hello!

The second warning says that the new say_hello conflicts with the old one. So, the old definition is kept (though the new definition is still available within the new Tmp module).

So, I think the only realistic way to use the workflow mentioned in the manual is to import the Tmp module and use the qualified Tmp.say_hello() in your test script.

2 Likes

Someone knowledgeable, please do improve this key section of the manual.

1 Like

The same thing happens when using the Revise.jl based workflow. Though I am not sure I am doing it correctly. Maybe it must be clarified in docs.

I have created an issue here.

In order for Revise to follow changes to the content, you need to type

includet("Tst.jl")

(note the t at the end). It’s easy to miss that the first time and I’m sure most of us have done it :frowning_face:

2 Likes

That works. Thanks. I had to first do includet("Tst.jl") and then again do include("Tst.jl") to execute the whole file.

I had not tried earlier with includet but with the Pkg centric usage. There the exported functions did not seem to update. But I might have done it wrong.