Julia's include function loads a source file and evaluates its contents in the current session. It lets you keep reusable function definitions in a file, load them without restarting the REPL, and reload the file after changing an implementation. section 2.5.1
Load reusable volume functions
Place sphere_volume, cylinder_volume, and cone_value in volumes.jl, then run include("volumes.jl"). Julia evaluates the definitions and returns the final result; subsequent calls such as cylinder_volume(1, 2) use the loaded functions. section 2.5.1
Listing 2.2 volumes.jl source code file
# Volume calculations sphere_volume(r) = 4π*r^3/3 cylinder_volume(r, h) = π*r^2*h cone_value(r, h) = π*r^2*h/3
Inspect the compact volumes.jl listing used to demonstrate file-based function definitions. section 2.5.1
include is an ordinary Julia function call, not a textual paste mechanism like C or C++ #include. It returns the value produced by the included file, can run inside a function, and evaluates definitions in the surrounding module. Package source files commonly use include inside a module so separate files become part of that module. section 16.2.2 section 16.4
Split a package across files
A ToyGeometry module can include volume.jl and trig.jl. This keeps a growing package manageable while placing both files' function definitions inside ToyGeometry. section 16.2.2
