5.4 KiB
PBS Dynamic Semantics Specification
Status: Draft v0 (Skeleton)
Applies to: runtime-observable behavior of PBS core programs
1. Purpose
This document will define the normative dynamic semantics of PBS core.
Its purpose is to make runtime behavior convergent across implementations by fixing:
- execution ordering,
- runtime evaluation of expressions and statements,
- abrupt completion and trap propagation,
- runtime behavior of effect surfaces such as
optionalandresult, - the execution boundary between ordinary PBS code, callbacks, contract calls, and host-backed calls.
2. Scope
This document is intended to define:
- the observable execution model of PBS core,
- evaluation order for expressions, statements, and blocks,
- runtime branch selection for
ifandswitch, - runtime application behavior for
apply, call sugar, methods, contracts, callbacks, and host-backed call surfaces, - runtime behavior of
optional,result<E>,else,!, andhandle, - abrupt completion (
return,break,continue) and trap propagation, - determinism requirements that affect execution behavior.
This document does not define:
- static typing or overload resolution rules,
- GC algorithm internals,
- exact IR shape or lowering passes,
- diagnostics catalog wording,
- the full PBX binary format.
3. Authority and Precedence
Normative precedence:
- Runtime authority (
docs/specs/hardware/topics/chapter-2.md,chapter-3.md,chapter-9.md,chapter-12.md,chapter-16.md) - Bytecode authority (
docs/specs/bytecode/ISA_CORE.md) 3. Core Syntax Specification.md4. Static Semantics Specification.md- This document
If a rule here conflicts with higher authority, it is invalid.
4. Normative Inputs
This document depends on, at minimum:
1. Language Charter.md3. Core Syntax Specification.md4. Static Semantics Specification.md5. Manifest, Stdlib, and SDK Resolution Specification.md6.2. Host ABI Binding and Loader Resolution Specification.md
This document is expected to be closed using decisions from:
docs/agendas/Dynamic Semantics - Execution Model Agenda.mddocs/agendas/Dynamic Semantics - Effect Surfaces Agenda.mddocs/agendas/Heap Model - Agenda.mddocs/agendas/Memory and Lifetime - Agenda.md
5. Already-Settled Inputs
The following inputs are already fixed elsewhere and must not be contradicted here:
- PBS prioritizes determinism and compatibility over ergonomics when the two conflict.
FRAME_SYNC-based execution semantics remain preserved.- No non-deterministic async execution model is part of PBS v1.
- Function application is defined on the canonical
applysurface, with call sugar desugaring toapply. bind(context, fn_name)evaluates thecontextexpression once at bind time.switchevaluates its selector expression once.optional Tfunction fallthrough yieldsnone.result<E>function fallthrough is a compile-time error.ok(...)anderr(...)are not ordinary first-class runtime constructors in v1 core.
6. Initial Section Targets
At minimum, the completed document should contain normative sections for:
- execution model and runtime state,
- evaluation order by construct,
- block execution and abrupt completion,
- runtime semantics of
optional, - runtime semantics of
result<E>, - runtime semantics of
apply, call sugar, and callable categories, - branching semantics for
ifandswitch, - traps, determinism, and host-call interaction.
7. A Ver
The following items remain to be closed in agenda discussion before this document can be considered complete.
7.1 Dynamic Semantics - Execution Model Agenda.md
- Exact observable execution model for PBS v1.
- Normative evaluation order for receivers, callees, arguments, selectors, and nested
apply. - Exact abrupt-completion model for
return,break,continue,!, and trap propagation. - Deterministic safepoint interaction around host calls, allocation-heavy operations, and loop back-edges.
7.2 Dynamic Semantics - Effect Surfaces Agenda.md
- Runtime value model of
optionalandresult<E>. - Eagerness and single-evaluation guarantees for
some(...),else,handle, and!. - Runtime artifact and cost model of
bind(context, fn_name). - Exact runtime boundary between explicit status values and true traps.
7.3 Heap Model - Agenda.md and Memory and Lifetime - Agenda.md
- Which dynamic-semantic costs are observable and later diagnosable.
- Which constructs may allocate, copy, retain, or cross the host-memory boundary during ordinary execution.
- Which memory and safepoint facts belong in this document versus
Memory and Lifetime Specification.md.
8. Non-Goals
- Reopening grammar or static typing unless current text is impossible to execute normatively.
- Defining exact GC collection strategy.
- Designing future async, actor, or scheduler models.
- Specifying backend optimization policy.
9. Exit Criteria
This document is ready to move beyond skeleton status only when:
- every runtime-observable core construct has a deterministic evaluation model,
- trap versus status-value behavior is explicit for every effect-bearing construct,
- host-call interaction rules are stated without relying on informal prose elsewhere,
- the document can drive runtime conformance tests without requiring agenda backfill,
- the document no longer depends on unresolved
A Veritems for core v1 behavior.