Need help?
Ask a question or report a problem on GitHub.
Open an issue
Modules
Split a program across files and reuse them with use.
Modules
Large programs need multiple source files.
Otter uses one keyword:
Output
use
Put use and a file path in quotes at the top of a file. The path is relative to the file that contains use, and it must match the file's name exactly, capital letters included, on every system (use "Helpers.ot" does not find helpers.ot, even on Windows). Everything the other file defines, such as its functions, is then available:
PowerShell
use "helpers.ot" greet "Ada"
Here helpers.ot, in the same folder, defines greet, and the program prints Hello, Ada. A file is loaded only once, even when several files use it, and files that use each other in a circle are reported as an error. Package names such as use web, use database or use json are not part of Otter 1.0: they stop the program with the error 'use' is not supported in Otter 1.0.
Otter
# helpers.ot to greet name say "Hello," name