lmcode_std_v3 (206 Signatures) + lmcode_std_rest_v1
LMCode Standard Catalog & REST Module
Every _lmcode_ block automatically receives the lmcode_std_v3
declaration surface (merged into the host schema by mergeLmcodeStd without changing the host schema's
SHA-256 identity). Filter all groups below.
Catalog Breakdown (206 Signatures)
| Group | Count | Types & Functions Included |
|---|---|---|
| file | 5 | file_read, file_write, file_append, file_exists, file_lines |
| math | 16 | math_abs, math_ceil, math_floor, math_max, math_min, math_pow, math_round, math_sqrt (int & float overloads) |
| string | 18 | str_len, str_contains, str_find, str_replace, str_split, str_upper, str_lower, str_trim, str_is_int, str_is_float, str_starts_with, str_ends_with, str_substr, str_repeat, str_match, str_to_int, str_to_float, template_render |
| encoding | 4 | str_base64_encode, str_base64_decode, str_hex_encode, str_hex_decode |
| json | 12 | json_parse(string) -> Json + 11 Json methods |
| collections | 58 | IntList, FloatList, StrList (+ join), IntMap, FloatMap, StrMap (+ keys/values snapshots) |
| containers | 69 | IntStack, FloatStack, StrStack, IntQueue, FloatQueue, StrQueue, IntPQ, FloatPQ, StrPQ (min-priority first, insertion-order ties) |
| return | 24 | lmcode_return_null, lmcode_return_set (11 overloads), lmcode_return_put (11 overloads), lmcode_return_put_null |
1. File I/O (5) & Math Overloads (16)
| Canonical Signature | Semantics |
|---|---|
fn file_read(string) -> string | Read raw bytes from path; raises located file_read: PATH: OS reason on error. |
fn file_write(string, string) -> void | Write raw bytes to path. |
fn file_append(string, string) -> void | Append raw bytes to path. |
fn file_exists(string) -> bool | Return true only for a regular file; missing and nonregular paths return false. |
fn file_lines(string) -> StrList | Split on every LF into a 0-indexed StrList, preserving CR and empty fields (including a trailing empty field). |
fn math_abs(int)->int / (float)->float | Absolute value (also math_min, math_max, math_pow, math_ceil, math_floor, math_round, math_sqrt). |
2. String Manipulation (18), Template Renderer & Byte Codecs (4)
| Canonical Signature | Semantics |
|---|---|
fn str_len(string) -> int | Byte length of string. |
fn str_contains(string, string) -> bool / fn str_find(string, string) -> int | Substring search (str_find returns 0-based byte offset or -1). |
fn str_replace(string, string, string) -> string / fn str_split(string, string) -> StrList | Replace all occurrences or split into StrList. |
fn str_substr(string, int, int) -> string | Byte substring by start and count; negative starts and overlong counts clamp, and nonpositive counts return empty. |
fn str_to_int(string) -> int / fn str_to_float(string) -> float | Strict complete-token numeric parsing; invalid input returns zero (use str_is_int / str_is_float to test validity). |
fn template_render(string, Json) -> string | One-pass StringTemplate-style renderer over a Json context (<path>, <items:{item|body}; separator=", ">, <if(cond)>...<else>...<endif>). |
fn str_base64_encode(string) -> string / fn str_base64_decode(string) -> string | Canonical padded RFC 4648 §4 Base64 codec. |
fn str_hex_encode(string) -> string / fn str_hex_decode(string) -> string | Lowercase hex encoder and mixed-case ASCII hex decoder. |
3. Immutable Json Navigation (12 Signatures)
| Canonical Signature | Semantics |
|---|---|
fn json_parse(string) -> Json | Parse strict UTF-8 JSON (depth ≤ 256, duplicate keys and BOM rejected). Also target of json <<~TAG literals. |
method Json.kind() -> string | Returns "null", "bool", "int", "float", "string", "array", or "object". |
method Json.len() -> int / method Json.at(int) -> Json | Array/object size and 0-based array element lookup. |
method Json.has(string) -> bool / method Json.get(string) -> Json / method Json.keys() -> StrList | Object field membership, lookup, and insertion-ordered key snapshot. |
method Json.as_int() -> int / as_float() -> float / as_bool() -> bool / as_string() -> string | Typed scalar extraction (raises RUN_HOST on kind mismatch). |
method Json.to_json() -> string | Compact canonical UTF-8 JSON serialization. |
4. Typed Lists (IntList, FloatList, StrList) & Insertion-Ordered Maps (IntMap, FloatMap, StrMap)
| Family | Constructors & Methods |
|---|---|
IntList, FloatList, StrList |
Constructors: int_list(), float_list(), str_list() (or qi(...), qf(...), qw(...)).Methods: .len() -> int, .at(int) -> T, .set(int, T) -> self, .add(T) -> self, .clear() -> self, .contains(T) -> bool, .index_of(T) -> int, plus StrList.join(string) -> string. |
IntMap, FloatMap, StrMap |
Constructors: int_map(), float_map(), str_map() (or %(k => v)).Methods: .len() -> int, .has(string) -> bool, .get(string) -> T, .get_or(string, T) -> T, .set(string, T) -> self, .remove(string) -> bool, .clear() -> self, .key_at(int) -> string, .keys() -> StrList, .values() -> TList. |
5. Stacks, FIFO Queues & Min-Priority Queues (69 Signatures)
| Container Family | Constructors & Methods |
|---|---|
IntStack, FloatStack, StrStack | int_stack() / float_stack() / str_stack() — .push(T) -> self, .pop() -> T, .peek() -> T, .at(int) -> T (in pop order), .len() -> int, .empty() -> bool, .clear() -> self. |
IntQueue, FloatQueue, StrQueue | int_queue() / float_queue() / str_queue() — .push(T) -> self, .pop() -> T, .peek() -> T, .at(int) -> T (in pop order), .len() -> int, .empty() -> bool, .clear() -> self. |
IntPQ, FloatPQ, StrPQ | int_pq() / float_pq() / str_pq() — .push(T, float priority) -> self, .pop() -> T, .peek() -> T, .len() -> int, .empty() -> bool, .clear() -> self. Priorities must be finite. |
6. Return Sink Helpers (24 Signatures) & $return Syntax
Write structured results to the per-slot return sink using either the 24 lmcode_return_* functions
or compiler return assignments:
fn lmcode_return_null() -> void(or$return = null;)fn lmcode_return_set(T) -> voidforbool,int,float,string,Json,IntList,FloatList,StrList,IntMap,FloatMap,StrMap(or$return = expr;)fn lmcode_return_put(string, T) -> voidfor all 11 types above (or$return.key = expr;/$return[keyExpr] = expr;)fn lmcode_return_put_null(string) -> void(or$return.key = null;)
7. Opt-In Module: lmcode_std_rest_v1 (18 Signatures + RestHandler)
Hosts that opt in to std/rest/lmcode-rest.schema.json can serve HTTP/1.1 messages directly over
stdin → stdout without opening a network socket:
rest_server.lms
prog = _lmcode_ schema="rest-host.schema.json";
@get_user
fn handle_user(x: RestExchange) -> void implements RestHandler {
let n = x.increment("hits");
x.json("{\"id\":\"" + x.param("id") + "\",\"hits\":" + str(n) + "}");
}
rest_route("GET", "/users/{id}", "get_user");
rest_serve();
end _lmcode_