ASPL لباتASPL 0.7.0

Search documentation

Search starts with current English documentation · ASPL 0.7.0

Enter a complete name such as read_line, or words about a topic.

    العربية
    Source files

    Open one UTF-8 .aspl or .لبات file, up to 1 MiB, in a new draft. It stays in this browser and does not run automatically.

    Typed lists

    ASPL 0.7.0 · Current release

    Current 0.7.0 operations, host support, examples, and failure rules.

    On this page

    Typed list values

    In ASPL 0.7.0, قائمة<T>/list<T> is a growable sequence of one exact storable element type, supported in the browser and natively. Type arguments use angle brackets; square brackets construct values. Nested lists, records, and results are allowed. unit elements and whole-list equality are rejected during checking.

    A nonempty literal infers its element type without numeric coercion. An empty literal needs an expected type from a binding, assignment, argument, or return. Elements evaluate in written order; a trailing comma is allowed.

    Illustrative fragment

    let empty: list<i64> = [];
    let values: list<i64> = [3, 4, 5,];

    Reading elements

    طول/length: (list<T>) -> i64 returns the element count in constant time. values[index] reads an element by value. The index has type i64 and starts at zero; negative indexes and indexes at or beyond the length trap with list-index-out-of-bounds.

    Browser and native · ASPL 0.7.0 · English source

    Execution: Browser and native · ASPL 0.7.0

    Prerequisites:
    • No prior knowledge is required to open and check it.

    Input: No input lines are required.

    fn total(values: list<i64>) -> i64 {
        return values[0] + values[1] + values[2];
    }
    fn start_main() -> i64 {
        let values: list<i64> = [3, 4, 5];
        if (length(values) not match 3) { return 1; }
        if (total(values) not match 12) { return 2; }
        let bytes: list<u8> = [0, 255];
        if (length(bytes) not match 2 or bytes[0] not match 0 or bytes[1] not match 255) { return 3; }
        let fractions: list<f64> = [0.5];
        if (fractions[0] not match 0.5) { return 4; }
        print("12");
        return 0;
    }
    
    Download lists.aspl

    Expected outcomes
    {
      "browser": {
        "check": "success",
        "class": "success",
        "output": "12",
        "processStatus": 0
      },
      "native": {
        "check": 0,
        "status": 0,
        "output": "12"
      }
    }

    Mutation and independent copies

    أضف/append takes a mutable list location and one value of exactly its element type, adds the value, and returns unit. Indexed assignment replaces an existing element; it does not grow the list. Both require a متغير/var root binding. A دع/let binding, function parameter, temporary value, or result payload projection is not a mutable location.

    Assignment, arguments, returns, and aggregate fields copy values. Mutating a copy, including a nested list, leaves other copies unchanged. The runtime can share storage until mutation, but it does not expose shared mutable aliases. Mutation resolves indexes left to right once, before evaluating the new value. append(xs, xs[0]) is valid.

    Browser and native · ASPL 0.7.0 · English source

    Execution: Browser and native · ASPL 0.7.0

    Prerequisites:
    • No prior knowledge is required to open and check it.

    Input: No input lines are required.

    fn start_main() -> i64 {
        var xs: list<i64> = [1, 2];
        append(xs, 3);
        if (length(xs) not match 3) { return 1; }
        var copy: list<i64> = xs;
        copy[0] = 9;
        if (xs[0] not match 1) { return 2; }
        if (copy[0] not match 9) { return 3; }
        append(xs, xs[0]);
        if (length(xs) not match 4) { return 4; }
        if (xs[3] not match 1) { return 5; }
        var nested: list<list<i64>> = [[1], [2]];
        let nested_copy: list<list<i64>> = nested;
        nested[0][0] = 7;
        if (nested_copy[0][0] not match 1) { return 6; }
        if (nested[0][0] not match 7) { return 7; }
        var grown: list<i64> = [];
        var k = 0;
        while (k < 32) { append(grown, k * 2); k = k + 1; }
        if (length(grown) not match 32) { return 8; }
        if (grown[31] not match 62) { return 9; }
        grown[0] = grown[31];
        if (grown[0] not match 62) { return 10; }
        var bytes: list<u8> = [0, 255];
        var byte_copy: list<u8> = bytes;
        byte_copy[0] = 255;
        if (bytes[0] not match 0 or byte_copy[0] not match 255) { return 11; }
        var fractions: list<f64> = [0.5];
        fractions[0] = 1.5;
        if (fractions[0] not match 1.5) { return 12; }
        print("32");
        return 0;
    }
    
    Download list-mutation.aspl

    Expected outcomes
    {
      "browser": {
        "check": "success",
        "class": "success",
        "output": "32",
        "processStatus": 0
      },
      "native": {
        "check": 0,
        "status": 0,
        "output": "32"
      }
    }

    Storage and failures

    Numeric list slots preserve their exact widths, as described in numeric storage. Length and capacity differ; there is no public byte view or C-layout promise. Runtime-owned lists and their retained elements count against execution memory. Resource limits or allocation failure do not expose a partially committed mutation.

    Checking rejects mismatched element types, untyped empty literals, invalid mutation targets, and immutable mutation. An out-of-bounds access is an uncatchable trap, not a recoverable result.

    Scope and complete examples

    Lists extend the historical MVP. Read every supplied variant in typed lists and list mutation, or continue to records and value semantics.

    Browse pages