Skip to content

Commit

Permalink
REPL docs for __init__ (JuliaLang#31930)
Browse files Browse the repository at this point in the history
  • Loading branch information
Moelf authored and vtjnash committed May 14, 2019
1 parent 95c95b6 commit 0523d1d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions base/docs/basedocs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,29 @@ end
"""
kw"module"

"""
__init__
`__init__()` function in your module would executes immediately *after* the module is loaded at
runtime for the first time (i.e., it is only called once and only after all statements in the
module have been executed). Because it is called *after* fully importing the module, `__init__`
functions of submodules will be executed *first*. Two typical uses of __init__ are calling
runtime initialization functions of external C libraries and initializing global constants
that involve pointers returned by external libraries.
See the [manual section about modules](@ref modules) for more details.
# Examples
```julia
const foo_data_ptr = Ref{Ptr{Cvoid}}(0)
function __init__()
ccall((:foo_init, :libfoo), Cvoid, ())
foo_data_ptr[] = ccall((:foo_data, :libfoo), Ptr{Cvoid}, ())
nothing
end
```
"""
kw"__init__"

"""
baremodule
Expand Down

0 comments on commit 0523d1d

Please sign in to comment.