Skip to content

2: Writing your first program in PRSE

Daniel Ellingson edited this page Jun 24, 2025 · 1 revision

The very basics - compilable but won't output anything yet:
Variable declarations:

let foo: int = 2;
let bar: char = 'e';
let baz: double = 4.65;

Use statements:

use "io"
use "math"

Converting datatypes:

let foo: int = 2;
let bar: string = foo$string;

PRSE programs usually contain the following:
If writing the main program - a main function:

function main(){

}

At the top of the file - zero, one, or more use statements:

use "io", "math", "algorithm"

At the top of the file, after your use statements - zero, one, or more variable declarations, or function definitions, or any combination thereof:

let x: int = 2;

function addOne(y: int){
    y += 1;
}

function main(){
    addOne(x);
}

All variable declarations--and expressions--must end with a semicolon character (;).


In the main function, or any function for that matter

Functions may contain any valid expression or expressions. By default, if no return type is specified, e.g.:

function notype(){

}

that function is void by default. To make a function non-void, specify a return type as follows:

function sometype(): string{
   return "a string";
}

Clone this wiki locally