The q* stdlib docs
qobject: map operations
qobject is the map counterpart to qarray: it exposes the object.* built-ins for inspecting and combining ordered maps. A Value::Map in Qirava is an ordered list of (key, value) entries, and object.* preserves that order in everything it returns. Functions take the map as the first positional argument and follow the shared DMS convention, so they are callable inline from QQL.
What it gives you#
qobject registers six public built-ins. The first positional argument is always the map; functions that need a key take it as the second positional argument. Output is a Record with a single "result" key.
| Function | Arguments | Returns | Behavior |
|---|---|---|---|
| object.keys | map | List of Str | All keys, in insertion order. |
| object.values | map | List | All values, in insertion order. |
| object.len | map | Int | Number of entries. |
| object.has | map, key | Bool | True if the key is present. |
| object.get | map, key | Value | The value for the key, or Null if absent. |
| object.merge | map a, map b | Map | a with b merged on top (b overrides a). |
Ordering and merge semantics#
Maps are ordered. object.keys and object.values iterate entries in their existing order. object.merge(a, b) starts from a copy of a; for each entry in b, if the key already exists in a its value is overwritten in place (keeping a's position), and if the key is new it is appended after a's keys. So the resulting key order is: all of a's keys (in a's order), then any keys that appear only in b (in b's order).
- key argument coercion
- The key (second positional arg) is read as a Str. An Int key is converted to its decimal string; any other non-string type becomes the empty string.
- override
- In object.merge, b's value wins for keys present in both maps.
Resource budget#
Each call decodes the argument map, and keys/values/merge re-emit a list or map of comparable size. Cost scales with the input map, so every object.* function declares a fixed 4096-byte (4 KB) memory budget and zero storage.
Example#
Merging {a:1, b:2} with {b:9, c:3}: key b is overridden to 9 in its original position, and the new key c is appended. The result has three entries in the order a, b, c.
Request
object.merge({a: 1, b: 2}, {b: 9, c: 3})
# wire form:
{ "0": { "Map": [ ["a", {"Int": 1}], ["b", {"Int": 2}] ] },
"1": { "Map": [ ["b", {"Int": 9}], ["c", {"Int": 3}] ] } }Response
{ "result": { "Map": [ ["a", {"Int": 1}], ["b", {"Int": 9}], ["c", {"Int": 3}] ] } }Output
{a: 1, b: 9, c: 3}Request
object.has({a: 1, b: 2}, "b")
object.get({a: 1, b: 2}, "a")Response
{ "result": { "Bool": true } }
{ "result": { "Int": 1 } }Output
true
1