Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concise info on creating and using a module without core and base #46628

Merged
merged 6 commits into from
Sep 12, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion doc/src/manual/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,30 @@ include(p) = Base.include(Mod, p)
end
```

If even `Core` is not wanted, a module that imports nothing and defines no names at all can be defined with `Module(:YourNameHere, false, false)` and code can be evaluated into it with [`@eval`](@ref) or [`Core.eval`](@ref).
If even `Core` is not wanted, a module that imports nothing and defines no names at all can be defined with `Module(:YourNameHere, false, false)` and code can be evaluated into it with [`@eval`](@ref) or [`Core.eval`](@ref):
```jldoctest
julia> arithmetic = Module(:arithmetic, false, false)
Main.arithmetic

julia> @eval arithmetic add(x, y) = $(+)(x, y)
add (generic function with 1 method)

julia> """
add(x, y)

vtjnash marked this conversation as resolved.
Show resolved Hide resolved
This sums up `x` and `y` and returns the result.
"""
arithmetic.add
Main.arithmetic.add

help?> arithmetic.add
add(x, y)

This sums up x and y and returns the result.

julia> arithmetic.add(12, 13)
25
```

### Standard modules

Expand Down