Skip to content

๐Ÿ™Š ExportPublic.jl: Easily hide your implementation details

License

Notifications You must be signed in to change notification settings

hayesall/ExportPublic.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

8 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

ExportPublic.jl: Easily hide your implementation details

This is a fork of ExportAll.jl that helps you write modules with public and private symbols.

If something starts with an underscore _, it will not be exported.

module SimpleMathExample
  using ExportPublic

  _secret_pi = 22/7                         # Private
  my_pi = _secret_pi                        # Public

  function add_squared(a::Int, b::Int)      # Public
    _squared(a) + _squared(b)
  end

  function _squared(a::Int)                 # Private
    a ^ 2
  end

  @exportPublic()                           # <--- Export our Public symbols
end

The "Public" symbols are automatically exported:

julia> include("SimpleMathExample.jl")
julia> using .SimpleMathExample
julia> add_squared(5, 5)
50
julia> my_pi
3.142857142857143
julia> _secret_pi
ERROR: UndefVarError: _secret_pi not defined
julia> _squared(5)
ERROR: UndefVarError: _squared not defined

About

๐Ÿ™Š ExportPublic.jl: Easily hide your implementation details

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages