Skip to content

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.

prismio
import std.io

fn main() {
    println("Hello, Prismio!")
}

Save the exact program as hello.psm. The .psm extension identifies Prismio source.

The few lines in the example establish several core rules:

  • fn main() declares the process entry point.
  • { and } delimit the function body.
  • println selects the String overload from the auto-loaded source standard library.
  • Reaching the closing brace reports successful completion to the operating system: the exit status is 0. A program that wants another status writes fn main() -> Int and returns it, as the next example does.

Save the file as hello.psm, then run it directly:

bash
prismio run hello.psm

Expected output:

text
Hello, Prismio!

run compiles a temporary native program and executes it. A compiler diagnostic stops the process before execution.

Or build a native executable:

bash
prismio build hello.psm -o hello
./hello

On Windows, choose an .exe output name and run it from PowerShell:

powershell
prismio build hello.psm -o hello.exe
./hello.exe

The 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:

prismio
import std.io

fn main() -> Int {
    let version: Int = 1
    println("Prismio language version")
    println(version)
    return 0
}

This main says -> Int and return 0 out loud, which is the same program. The two go together: a main with no return type exits with status 0 on its own, while one that writes -> Int must return its status on every path.

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 return from an Int-returning function other than main fails definite-return analysis. main alone may end without one: it returns 0.
  • 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.