Skip to main content

Module semantics

Module semantics 

Source
Expand description

Value model, environment, and type resolution — a port of the reference implementation’s semantics.ts.

Structs§

ArrV
an array value
AssertItem
an assertion or a guarded group of a record type
Closure
a function value: its parameters, its body, the scope it closed over
ConstEntry
a constant’s declaration and memoized value
Diag
a diagnostic (§6, §12)
DiagDecl
a diagnostic template’s declaration
Env
the environment of a module: its declarations, its imports, its roots and diagnostics, the unit space
EvalErr
an evaluation error, with its code when it has one
Export
an exported name: the environment declaring it
FuncEntry
a function’s declaration
MapV
a map value
Member
a member of a resolved record type
NsRefV
a namespace’s exports
PreValV
an expression waiting to be evaluated in its scope
RecInst
a record instance: its type, its path, its slots
RecType
a record type’s shape
Scope
an evaluation scope: the enclosing instance, the local variables, the root, the module environment
Slot
a member’s slot in an instance
Ty
a resolved type: its kind, its name when named, its else tail
TypeEntry
a type’s declaration
UnitDecl
a unit’s declaration

Enums§

Compute
how a slot computes its value
Fail
why an evaluation stopped
MKind
a member’s kind (§5)
RTk
the kinds of resolved types (§3)
Seg
a segment of a canonical path (§7.2)
SlotState
the state of a slot
Value
a runtime value (§9): the scalars, quantities, references, and instances, and the engine’s intermediate forms

Functions§

cmp_path
Canonical path order (§7.2): segment-wise, indices numerically, names and keys lexicographically, a prefix first.
compile_pattern
Compile a pattern body to a regular expression.
dot_spellable
dot-spellable (§3.11, §4.3): identifier-shaped and not a literal keyword
err
An evaluation error without a code.
err_code
An evaluation error with a code.
is_rec
Whether the type is a record.
js_num_str
ECMAScript Number::toString for finite doubles (shortest round trip)
json_str
A string as JSON text, escaped.
key_of_vec
The dimension’s key (Length*Time^-1).
parse_path
A path string from a document: .name is a member, ["…"] a bracketed segment (a map key, or a member the dot cannot spell — the canonical walk, §7.5, decides which is legal where), [n] an index.
path_str
A canonical path’s text, relative to rel_root ($.…) when given.
pattern_error
Why a pattern body is outside the §3.6 core (E4119), when it is.
read_json
Read a JSON document (§10.2): objects keep their key order, integers stay exact; trailing characters are an error.
rec_members
The members of a record type; empty for any other type.
rec_type
An empty record type.
seg_text
A segment’s text as the path spells it.
sort_diags
§6.7: evaluation- and validation-time diagnostics sort by (path, id), path in canonical order; stable
subst_expr
Substitute values for names in an expression.
subst_type
Substitute a generic type’s parameters (§3.15).
ty
A resolved type of a kind.
value_eq
Structural equality of two values (§4.5).
vec_combine
Two dimensions multiplied (sign 1) or divided (sign -1).
vec_of_key
A dimension from its key.

Type Aliases§

ConstEval
evaluates a constant by name (the engine’s)
DimVec
a dimension as base dimensions with exponents
ExprEval
evaluates an expression (the engine’s)
NatFn
a native function
R
an evaluation’s outcome
RT
a resolved type, shared
SegPath
a canonical path