Skip to content

JuliaAPlavin/Autoloads.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Autoloads.jl

Autoloads.jl lets you load a package whenever a symbol from that package is used in the REPL.

Packages are automatically installed if not present in the current environment. Just add Autoloads to your default environment, register it in your startup.jl following this snippet:

if isinteractive()
    import Autoloads
    Autoloads.register_autoloads([
        ["@test", "@testset"]    => :(using Test),
        ["@b", "@be"]            => :(using Chairmarks),
        # ...
    ])
end

and enjoy the benefits at the REPL!

For example:

# no manual imports needed
julia> @test 1+1 == 2
[ Info: executing `using Test`  # the package is loaded when it's first required
Test Passed

julia> @test 1+1 == 2
Test Passed

julia> median([1,2,3])
[ Info: executing `using Statistics`
2.0

julia> mad([1,2,3])
[ Info: executing `using StatsBase`
 │ Package StatsBase not found, but a package named StatsBase is available from a registry. 
 │ Install package? <...>
1.4826022185056018

Differences from BasicAutoloads.jl

Autoloads (this package) reuses a lot of BasicAutoloads code to register REPL transforms. Autoloads supports the autoloads definitions from BasicAutoloads to enable seamless switching if needed.

These packages differ in a fundamental aspect of how the code transform operates. BasicAutoloads triggers the target execution whenever a specified symbols appears in the code - in any capacity, including new definitions or name clashes. See some related issues: 1, 2, 3. Meanwhile, Autoloads (this package) only triggers when the global variable of such a name is actually referenced in the code and isn't already defined. BasicAutoloads is likely to have smaller TTFX though, manifested as startup time or delays on the first code execution in the REPL.

About

Automatic package loading and dependency management utilities.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages