LEARN VOID / FOUNDATIONS
Modules & imports
Organize a program into small source files.
Complete program for the synchronous entry adapter. The result below is the returned integer.
use "/pricing.void" as pricing
use "./delivery.void"
func entry(items: i32) -> i32:
return pricing.subtotal(items) + delivery_fee()Keep the module paths together
Download the entry file and supporting sources below. Save them with the displayed filenames, including the nested details/rates.void path. The entry file’s parent establishes the virtual project root.
main.void
pricing.void
delivery.void
details/rates.voiduse "details/rates.void" as rates
func subtotal(items: i32) -> i32:
return items * rates.unit_price()func delivery_fee() -> i32:
return 3Use qualified and direct names
The absolute project-root import is aliased as pricing, so its function is called as pricing.subtotal. The relative delivery import exposes its unambiguous name directly. Five items at four plus delivery of three return 23.
Read paths in project context
A leading slash refers to the virtual project root, not the operating-system root. A quoted path, with or without ./, resolves from the importing file. Exact-case .void filenames and forward slashes are required. Parent paths remain bounded by the project root; a package manager is not supplied.
Follow paths from the importing file
use "details/rates.void" as rates inside pricing resolves from that file’s directory, just like ./details/rates.void. Keep the directory when downloading this supporting module.
func unit_price() -> i32:
return 4use io/memory as memory imports the standard source io/memory.void. The alias supplies the name in the importing module. An absolute VOID_STDLIB_ROOT selects a standard-source root. Project-local library sources use use lib/.... Standard sources cannot import quoted project files. See Binary values and memory streams.
Find the project entry deliberately
With a compatible local compiler, voidc run . discovers main.void. Directory-based check, build and emit use the same discovery. From an active file, discovery looks for the nearest exact main.void through parent directories up to the workspace boundary. Without an active file, only the workspace root is checked; there is no recursive search. An explicitly selected entry wins, source errors never trigger a fallback, and the selected entry remains fixed during a session until deliberately changed or restarted.
The complete source above uses the legacy entry(i32) adapter: run it with a numeric input. See application entry for a main-based program. For a source installation, follow the platform prerequisites and installation guide.