Export statements make selected functions and types from a Julia module available without repeating the module name. They turn awkward calls such as ToyGeometry.sine into the simpler sine form while keeping other bindings module-qualified. section 16.3
Exporting custom trigonometric functions
Add `export sine, cosine` inside the module, then load it with `using ToyGeometry`. The REPL can call `sine(π/2)` and `cosine(π)` directly; without the export, `sine(π/2)` raises an undefined-variable error while `ToyGeometry.sine(π/2)` works. section 16.3
export sine, cosine #1
"""
sine(x)
Calculate the sine of an angle `x` given in radians
"""
function sine(x::Number)
n = 5
total = 0
for i in 0:n
total += (-1)^i*x^(2i+1)/factorial(2i + 1)
end
total
end
function cosine(x::Number)
n = 5
mapreduce(+, 0:n) do i
(-1)^i*x^(2i)/factorial(2i)
end
end
Shows the export declaration beside the complete `sine` and `cosine` implementations. section 16.3
The exported functions can then participate in ordinary Julia workflows:
- Compare custom and built-in trigonometric functions numerically. section 16.3
- Plot both implementations with CairoMakie using unqualified function names. section 16.3




