LEARN VOID / 01
Syntax basics
Read your first VOID program.
Complete program for the synchronous entry adapter. The result below is the returned integer.
# Three items fit in each box.
func entry(boxes: i32) -> i32:
return boxes * 3Read the function declaration
func entry(boxes: i32) -> i32: names a function, its integer input and its integer result. Here a box holds three items, so four boxes produce 12 items.
Use indentation for the body
The colon starts the body; indent its statements by four spaces. return boxes * 3 calculates and returns the item count. Ordinary blocks need no braces or statement-ending semicolons. A # comment explains the idea without affecting execution.
Understand the entry adapter
The current command-line adapter passes one i32 input to entry and displays its returned integer. The first example uses that adapter; the compiler selects the application entry below from its checked source. Use console.stdout for explicit output. Use descriptive lowercase snake_case names.
Choose an application entry point
For application execution, use voidc run main.void with a zero-argument synchronous main(). A main without a result exits successfully; a main returning i32 must return on every path. This short application deliberately returns status seven. That status belongs to the process and is not printed; standard output is empty. No numeric adapter input is passed.
func main() -> i32:
return 7Executable top-level statements are an alternative to main, not something to combine with it. This source executes in order and returns success when capacity is available. Run it with voidc run top-level.void.
var capacity = 24
var reserved = 6
var available = capacity - reserved
return if available > 0:
0
else:
1Top-level fallthrough or a bare return means status zero. File-level globals initialize before main or top-level execution. Nested block variables stay local, and imported modules cannot contain executable statements. Use the async host adapter for an async numeric entry. Application status and console output are independent.