SultanC
  1. Home
  2. Examples
  3. Basics

Module-level constants are evaluated before main runs

basics/constants.sn
// Module-level constants are evaluated before main runs.
import std.io.println;
import std.text.number;

let width: int = 16;
let height: int = 9;
let area: int = width * height;
let flags: int = (1 << 3) | (1 << 1);
let is_wide: bool = width > height;

def main(): int {
    println(int_to_text(area));
    println(int_to_text(flags));
    if (is_wide) {
        println("wide");
    };
    return 0;
}

Run it

With the interpreter, without compiling:

./build/sultanc run examples/en/basics/constants.sn

Or compile it to an executable:

./build/sultanc examples/en/basics/constants.sn -o build/example && ./build/example

Source on GitHub   All examples