PrivateModules

Make unexported symbols private.

Contents

Installation

This package is registered in METADATA.jl and so can be installed using Pkg.add

Pkg.add("PrivateModules")

Public Interface

# PrivateModulesModule.

Provides an @private macro for hiding unexported symbols and scoped import macro @local.

source

# PrivateModules.@privateMacro.

Make unexported symbols in a module private.

Signature

@private module ... end

Example

using PrivateModules

@private module M

export f

f(x) = g(x, 2x)

g(x, y) = x + y

end

using .M

f(1)      # works
M.g(1, 2) # fails

source

Methods

# PrivateModules.@localMacro.

Local import, importall and using macro.

Signature

@local expression

Examples

function func(args...)
    @local using A, ..B, C.D
    # ...
end

Exported symbols from A, ..B, and C.D are bound to local constants in func's scope.

function func(args...)
    @local importall A, ..B, C.D
    # ...
end

All symbols from A, ..B, and C.D are bound to local constants in func's scope.

function func(args...)
    @local import A, ..B, C.D
    # ...
end

A, B, and D are bound to local constants in func's scope.

Notes

  • Macros cannot be imported using the @local macro.
  • Modules listed in @local calls must be literals - not variables.

source

Methods

Internals

# PrivateModules.exportsFunction.

Signature

exports(outer, inner)

Import all exported symbols from inner module into outer one and then re-export them.

source

Methods