Book
Modules and std
Module-scoped imports. Userland printing goes through std.
Import one name
/ path binds a single name: the last path segment. Use exports as module.name. There is no star-import and no dumping symbols into the importer’s globals.
; app.echo: multi-file sketch (see examples/misc/multi)
/ std/io
/ std/str
/ ./lib
io.print(str.from_int(lib.add(20, 22)))
io.print(str.from_int(lib.answer))
; lib.echo
$ add = (a, b) {
^ a + b
}
$ answer = 42
\ add, answerstd and runtime
There is no free print. Go through std (for example io.print). / runtime is allowed only inside the privileged std package; userland cannot import it. Imported functions keep their defining-module return kind (str.from_int is a string). Import parameters stay unspecialized so one call site does not freeze later argument kinds.
Grow beyond one file
A module can be one Echo file or a folder of Echo files. Folder modules combine their files’ exports while keeping private names file-local. External host paths use the same import syntax after xo get installs the package. A project only needs xo.toml when it wants dependency pins.
Export
\ name (or a list) marks what the module exposes. Importers only see those names under the module object.