38 Stars
Updated Last
1 Year Ago
Started In
November 2016

⚠️ vvv Deprecation notice vvv ⚠️

This package has been deprecated and the repository archived. The functionality is supported natively in Julia 1.6 and above (see JuliaLang/julia#37396) with the following syntax:

import LinearAlgebra as LA

using LinearAlgebra: cholesky as c, lu as l

For earlier Julia versions it is recommended to use Compat.jl instead of this package. Compat.jl (version 3.21.0 and above) supports the same syntax as implemented in Julia 1.6 using the @copmat macro:

using Compat

@compat import LinearAlgebra as LA

@compat using LinearAlgebra: cholesky as c, lu as l

⚠️ ^^^ Deprecation notice ^^^ ⚠️


Build Status

Provides two macros: @import and @using which loads a module or object and binds it to an alias.


@import can be used with modules, or specific objects inside modules, to create an alias, and to hide the underlying module from the user code. For example

julia> using ImportMacros

julia> @import LinearAlgebra as LA

julia> LA.dot([1, 2], [3, 4])

creates an alias LA which is bound to the LinearAlgebra module. Note that the name LinearAlgebra is hidden and only the alias name is introduced in the calling scope:

julia> LinearAlgebra
ERROR: UndefVarError: LinearAlgebra not defined

A (shorter) alias can be useful, for example, if non-exported functions from modules are used frequently in the code. For instance, compare the two different ways of calling the function foo from the module MyLongModuleName:

alias.foo() # via the alias

MyLongModuleName.foo() # via the original module name

An alias can also be useful in order to load a package with a name that conflicts with your own code.

The syntax for @using is the same as for @import

@using MyLongModuleName as alias

but the result is roughly equivalent to

using LongModuleName
const alias = LongModuleName


The package can be installed with Julia's package manager, either from the Pkg REPL

pkg> add ImportMacros

or from the Julia REPL

julia> using Pkg; Pkg.add("ImportMacros")

Required Packages

No packages found.