Hello, Prismio
Compile and run a minimal Prismio 0.1 program.
Last verified
A Prismio executable starts in a top-level function named main. Function bodies are blocks, calls use parentheses, and statements do not use semicolons.
import std.io
fn main() -> Int {
println("Hello, Prismio!")
return 0
}Save the exact program as hello.psm. The .psm extension identifies Prismio source.
The four lines inside the example establish several core rules:
fn main() -> Intdeclares the process entry point and an integer exit status.{and}delimit the function body.printlnselects theStringoverload from the auto-loaded source standard library.return 0reports successful completion to the operating system.
Save the file as hello.psm, then run it directly:
prismio run hello.psmExpected output:
Hello, Prismio!run compiles a temporary native program and executes it. A compiler diagnostic stops the process before execution.
Or build a native executable:
prismio build hello.psm -o hello
./helloOn Windows, choose an .exe output name and run it from PowerShell:
prismio build hello.psm -o hello.exe
./hello.exeThe input file is also the import root. When this program later imports model.user, Prismio resolves it beneath the directory containing hello.psm.
println is declared in the shipped std/io.psm source module. The compiler loads it automatically before checking the program.
Make a small change
Print an integer on a second line:
import std.io
fn main() -> Int {
let version: Int = 1
println("Prismio language version")
println(version)
return 0
}let creates an immutable binding and the annotation fixes its type as Int. Exact overload resolution selects println(value: Int).
Common first errors
- Adding semicolons produces unsupported punctuation in statement positions.
- Writing top-level calls is invalid; executable statements belong inside a function.
- Omitting
returnfrom anInt-returning path fails definite-return analysis. - Integer output has exact overloads for every built-in signed and unsigned width; arithmetic and assignment still do not widen integers implicitly.
- Copying a command-line signature from another language may fail because 0.1 documents
main()without argument parameters.
Continue with the first complete program to add a helper function, mutable state, and a half-open range loop.