Is there a way to export ALL the symbols declared in a module? Just to avoid writing them all under export.


No. You typically don’t want to do this.


I am just following this tip:

which I find very useful. However since I am constantly changing the package, it is very inconvenient to track exported variables. So I think this is a use-case for exportall. Why is it so dangerous? I think it could be useful in certain scenarios.


I would prefix the module name before the functions you are using when developing (or do something like const m = MyPackage and use m.f().

For improved workflow, I would look at https://github.com/timholy/Revise.jl


What is the advantage of that, versus exportall? I am just trying to see the downside of having exportall as a feature.


Global namespace is global.


Julz has a function for exporting all vars (that were included using the package)

Maybe you can do something like this:


A practice which I like but I see others employ only rarely is putting export statements immediately following definitions like so

f(x::AbstractFloat) = # do some stuff
function f(x::Complex{<:AbstractFloat})
    # do some other stuff
export f

I agree that creating an exportall keyword would be asking for trouble.


Can you explain this code a bit? It seems to be exporting all files, not symbols of a module.


That does seem good for readability while the code is being written, but I wonder if it will become more difficult for other people (or a future you) to understand what the code does. Looking at a list of exports is one of the ways that I typically start to understand a new package.

I think I might try this style on my next project and see how it works…


I haven’t particularly found reading the export lists useful without a good handle on what the functions actually do. Sometimes having argument types is enough for this, but the names alone usually aren’t (for me at least).

Granted, it does make it easy to lose track of which functions are being exported.


Yea, I felt like exportall was a little dodgy (so I scoped it on files for Julz).

I believe the following code does exactly what you want

// at least it did in v0.5


The following simple snippet seems to work:

module Foo
        foo(x) = x+1
        bar(x) = x-1
        # exportall:
        for n in names(current_module(), true)
            if Base.isidentifier(n) && n ∉ (Symbol(current_module()), :eval)
                @eval export $n


@stevengj Sometimes I have a module spread over multiple files. Is there a way to specialize this to only export symbols defined in the current file?