RaggieScript v1.3.0
Browse Table of Contents (17 chapters)
Getting Started (2)
Language Reference (4)
Core Standard Library (3)
Windows, MSI SQL & Native FFI (3)
Wizard UI & Studio Sandboxes (3)
Diagnostics & Bytecode ISA (2)
Master Symbol Index
3 min read Module: raggiesoft.raggiescript F1: IDH_RSSC_TYPES (0x2004)

Gradual Type System, struct, enum, match & Closures

RaggieScript v1.0 features a gradual, type-inferred static type checker (BindAndVerifyProgram). Simple setup scripts can omit type annotations entirely and rely on local type inference, while larger engineering suites can annotate struct schemas, enum variants, and fn return contracts checked at compile time (RSW710–RSW715).

Built-In Primitive & Composite Types

Type AnnotationRuntime RepresentationAssignability & Widening Notes
int64-bit signed integer (int64_t)Widens automatically to float.
float64-bit IEEE double (double)Accepts both float and int.
boolBoolean (true / false)Strict in relational comparisons (RSW711 blocks < on bool).
stringUTF-8 stringInteroperates cleanly with path and string-backed enum variants.
pathNormalized filesystem pathSupports / path-join operator (sys.programFiles / "RaggieSoft" -> path).
version4-part SemVer (Major.Minor.Build.Rev)Compared component-wise (v"10.0.22631" > v"10.0.22000").
arrayOrdered list (T[] shorthand accepted)Indexed via arr[i]; supports len(arr), array.map, array.filter.
mapKey-value dictionarySupports dot-property m.key and bracket m["key"] access.
ref TMutable variable referenceRequired by two-way Wizard UI bind: ref myParam slots (const blocked by RSW713).
anyGradual dynamic escape hatchCompatible with any target or source type.

User-Defined Records (struct)

struct declarations define strongly checked record types with optional default field values. Passing an unknown field name or wrong field type in a struct literal raises RSW714 or RSW711 at compile time (with a fuzzy "Did you mean ...?" suggestion!):

struct EndpointConfig {
    host:       string = "https://raggiesoftstudio.com";
    port:       int    = 443;
    tlsVerify:  bool   = true;
}

const prod = EndpointConfig {
    port: 8443 // 'host' and 'tlsVerify' inherit their declared defaults!
};

Strongly-Typed Enumerations (enum)

enum declarations group named string or integer constants. Referencing a misspelled variant (ReleaseRing.Stabel) fails immediately at compile time with RSW714:

enum ReleaseRing {
    Stable  = "stable",
    Preview = "preview",
    Lts     = "lts"
}

param ring: ReleaseRing = ReleaseRing.Stable;

Pattern Matching (match)

match can be used as an expression (returning a value) or as a statement, with _ (or default) serving as the wildcard catch-all arm:

fn siliconBanner(arch: string) : string {
    return match (arch) {
        "arm64" => "Native Windows 11 ARM64 Build",
        "x64"   => "Native Windows 11 x64 Build",
        _       => "64-Bit Windows Build"
    };
}

Functions (fn) & First-Class Arrow Closures (=>)

User functions support typed parameters, default parameter expressions, return type annotations (verified on all control paths via RSW715), and mutual recursion.

First-class arrow closures (x => expr, (a: int, b: int) => expr, or () => { ... }) capture lexical variables from outer scopes and compile to MAKE_CLOSURE opcodes in the RSWBC2 stack VM:

// 1. Named typed function with default argument
fn formatPortEndpoint(host: string, port: int = 443) : string {
    return "${host}:${port}";
}

// 2. First-class closure passed to ui.textBox(validate: ...) or array.filter(...)
const minPort = 1024;
const isValidServicePort = (raw: string) => {
    const p = int(str.trim(raw));
    return (p >= minPort && p <= 65535)
        ? Validation.ok()
        : Validation.error("Enter a TCP port between ${minPort} and 65535.");
};

const ports = [80, 443, 8080, 9443];
const unprivileged = array.filter(ports, p => p >= minPort); // -> [8080, 9443]
Indexed API Calls & Symbols on This Page (3):