Executing code blocks with REPL workspace

Some combination of the following is helpful to me

  1. An exportall(mod::Module)` function
function exportall(mod)
    for n in names(mod, all = true)
        if Base.isidentifier(n) && n ∉ (Symbol(mod), :eval)
            @eval mod export $n
        end
    end
end

I have this in my startup.jl

  1. A main() function inside the module which looks like
function main()
@eval Main begin
    ...
end
end

The only problem is that you need to make sure you run exportall before main()

This has a nice combination of

  1. Revise.jl works
  2. You can play around with functions inside your module
  3. The temporary variables you make at the REPL aren’t visible inside your module, so you don’t accidentally define global things that get used in your module.
1 Like