Revise.jl
Revise.jl copied to clipboard
Exported variables not cleared in namespace
Hi thanks for the amazing package! I am new to Revise. This might be a known limitation. If I add a function name to the exported variable list, and then delete it, that variable name is still exposed.
on REPL I type
using Revise
using Example
and modify the Example
package by adding functions f
and g
module Example
export hello, domath, f, g
"""
hello(who::String)
Return "Hello, `who`".
"""
hello(who::String) = "Hello, $who"
"""
domath(x::Number)
Return `x + 5`.
"""
domath(x::Number) = x + 5
f() = π
g() = 2 * π
end
Everything works as expected.
Now if I remove g
from export list,
...
export hello, domath, f # g is removed
...
The function g
can still be accessed. Let me know if this is a known problem that cannot be easily circumvented.
Thank you!
Thanks for the comment! Yes, this is a Julia limitation. It would be nice to fix, though.
And if you edit "hello", if you are using it has:
using Example
hello()
The output won't be updated.
It works only with:
using Example # import/using doesn't matter what do you use since you have to specify the module
Example.hello()
For me (and I think many others), the module-scoping isn't necessary. Can you be more explicit about what you're doing? I'm guessing you redefined the Example
module (e.g., include("example.jl")
). But Revise doesn't require you to do that, and indeed it's much better not to do that. Just using
/import
your packages and edit them without explicitly reloading any files. If this doesn't work for you then maybe you're on a file system where FileWatching fails and you need to turn on polling (see the docs).
For me (and I think many others), the module-scoping isn't necessary. Can you be more explicit about what you're doing? I'm guessing you redefined the
Example
module (e.g.,include("example.jl")
). But Revise doesn't require you to do that, and indeed it's much better not to do that. Justusing
/import
your packages and edit them without explicitly reloading any files. If this doesn't work for you then maybe you're on a file system where FileWatching fails and you need to turn on polling (see the docs).
maybe is a dumb question, how to you import a module you have in a custom file under your src? i thought you are forced to "include" the file first.
This is exactly what I'm doing:
# main.jl
using Revise
include("./example.jl")
using .Example
hello()
# Hello world!
# example.jl
module Example
export hello
function hello()
println("Hello world!")
end
end
I edit example.jl
to print just "Hello" but I can't make hello()
print the new value without specifying the module in the main.jl
I've tried all the combinations:
- execute
main.jl
-> edit -> executemain.jl
includingusing Revise
- execute
main.jl
-> edit -> executemain.jl
excludingusing Revise
- execute
main.jl
-> edit -> executemain.jl
excludingusing Revise
andinclude("./example.jl")
- execute
main.jl
-> edit -> executemain.jl
includingusing Revise
but excludinginclude("./example.jl")
I'm doing everything in the REPL basically pressing ctrl+enter with the vscode extension I've killed the REPL at each try.
includet("./example.jl")
(note the t
)
includet("./example.jl")
(note thet
)
Thank you! it works, I've read the docs but i didn't quite get what was the purpose of includet