Imports
Split programs across files with use:
use "math-lib.ilo"All declarations from the imported file merge into a flat namespace - no modules, no qualification.
Full import
Section titled “Full import”-- math-lib.ilodbl n:n>n;*n 2half n:n>n;/n 2sq n:n>n;*n n-- main.ilouse "math-lib.ilo"
round-trip n:n>n;h=half n;r=dbl h;+r 0hyp-sq a:n b:n>n;sa=sq a;sb=sq b;+sa sbilo main.ilo round-trip 10# -> 10
ilo main.ilo hyp-sq 3 4# -> 25Scoped imports
Section titled “Scoped imports”Import only specific functions with a bracketed list:
use "math-lib.ilo" [dbl sq]Now only dbl and sq are available. half is not imported. Requesting a name that does not exist in the file is an error (ILO-P019).
Import rules
Section titled “Import rules”- Paths are relative to the importing file’s directory
usemust appear at the top of the file, before any function definitions- Imports are transitive: if
a.ilousesb.ilo, thenmain.ilousinga.ilogetsb.ilo’s declarations too - Circular imports are detected and reported as an error (
ILO-P018) - All imported functions are type-checked as part of the full program
usein inline mode (no file context) is an error (ILO-P017)
Multi-file example
Section titled “Multi-file example”-- validators.ilopositive n:n>b;>n 0in-range n:n lo:n hi:n>b;a=>=n lo;b=<=n hi;?a{true:b;false:false}-- app.ilouse "validators.ilo" [positive in-range]
check-age age:n>t;?{positive age:?(in-range age 0 150){true:"valid";false:"out of range"};false:"negative"}