Your First Program
Explore structs and field access with a complete repository example.
After Hello World, explore a struct with two fields. This example is the complete, unchanged examples/native/struct_basic.sio.
The complete program
// Struct literal construction and field access in native-v2 driver.
// Expected: prints "7", exits 0.
struct Point { x: i64, y: i64 }
fn main() -> i64 with IO {
let p = Point { x: 3, y: 4 }
let s = p.x + p.y
print_int(s)
print_char(10)
0
}
struct Point defines a type with named fields. Point { ... } constructs a value, and p.x and p.y access its fields. The printing functions use the IO effect. The final expression 0 is the return value of this main.
Check and run
Complete the platform setup first, including the native build if you use macOS ARM64. From the repository root:
export SOUNIO_STDLIB_PATH="$PWD/stdlib"
./bin/souc check examples/native/struct_basic.sio
./bin/souc run examples/native/struct_basic.sio
Run only after the check succeeds. The source comment specifies the expected output 7 and exit status zero. These are comparison criteria, not a fresh execution result. Keep the actual output, exit status, and compiler identity from your environment.
Continue with your own program
Copy the example into a separate file and change one field at a time, then check and run your version.
This example teaches ordinary structs. A struct named KnowledgeF64 with value, uncertainty, and confidence fields does not implement Knowledge<T> or establish uncertainty propagation, provenance, or confidence enforcement. For the documented epistemic APIs and their limits, follow the programming guide and known limitations.