RSS basics

RSS is the RustScript source language. A program imports only the modules or host namespaces it uses, declares bindings and types, and evaluates expressions or calls host functions.

Imports and host calls

use imports a module or host namespace. Host capabilities remain under the namespace supplied by the embedding runtime.

use bytes;
use re;
use runtime;

let regex_ok = re::match("(?i)^rustscript$", "RUSTSCRIPT");
let packet = b"pd\x01";
let packet_hex = bytes::to_hex(packet);
assert(bytes::from_hex(packet_hex) == packet);
let sleep_ok = runtime::sleep(100);

Bindings, mutation, and types

Use let for a binding and let mut when the binding changes. A type annotation follows the binding name.

struct Stats {
    score: int
}

struct Profile {
    stats: Stats
}

let mut total = 0;
for i in 0..4 {
    total = total + i;
}

The declaration and loop forms are present in examples/example_complex.rss.

Blocks return their final expression

if and function blocks use their final expression as the result. A trailing semicolon changes an expression into a statement, so keep the result expression as the final item when a value is required.

let total = if !string::non_empty("rustscript") => {
    let zeroed = 0;
    zeroed
} else => {
    let bumped = total + 1;
    bumped
};

See the RSS language for the complete accepted syntax and host functions for the embedding contract.