prep.2 — Term::New construct ((new T args...) Form-A keyword) #32

Closed
opened 2026-05-28 13:42:22 +02:00 by Brummel · 0 comments
Owner

Second iteration of the kernel-extension-mechanics arc. Depends on prep.1 for the type-scoped resolution it relies on.

Goal. Add a new term construct (new T arg1 arg2 ...) that calls the new def in T's home module. T is a TypeName; args may be Type expressions or Term expressions (parser disambiguates by syntactic form). The construct is the canonical functional-construction form, complementary to (not replacing) term-ctor for named-data-ctor ADT construction.

Scope (from spec § Iteration prep.2):

  • New AST variant Term::New { type_name: TypeName, args: Vec<NewArg> } with NewArg = NewArg::Type(Type) | NewArg::Value(Term) in ailang-core/src/ast.rs. Serialised as { "t": "new", "type": "...", "args": [{ "kind": "type|value", "value": ... }] }.
  • Form-A surface: new keyword new in lex/parse. Production '(' 'new' <TypeName> <NewArg>+ ')'. Round-trip preserved.
  • Checker: resolve type_name via type-scoped lookup (prep.1's mechanism) to its home module, find new def, check arg-kind against signature.
  • Two new diagnostics: NewTypeNotConstructible, NewArgKindMismatch.
  • new reserved as Form-A keyword — verified collision-free in workspace (grounding-check confirmed no existing def named new).
  • Drift pin: term_new_round_trips.

Spec: docs/specs/2026-05-28-kernel-extension-mechanics.md § Iteration prep.2.

Whitepaper: design/models/kernel-extensions.md § 2. The new term construct.

Second iteration of the `kernel-extension-mechanics` arc. Depends on prep.1 for the type-scoped resolution it relies on. **Goal.** Add a new term construct `(new T arg1 arg2 ...)` that calls the `new` def in T's home module. T is a TypeName; args may be Type expressions or Term expressions (parser disambiguates by syntactic form). The construct is the canonical functional-construction form, complementary to (not replacing) `term-ctor` for named-data-ctor ADT construction. **Scope (from spec § Iteration prep.2):** - New AST variant `Term::New { type_name: TypeName, args: Vec<NewArg> }` with `NewArg = NewArg::Type(Type) | NewArg::Value(Term)` in `ailang-core/src/ast.rs`. Serialised as `{ "t": "new", "type": "...", "args": [{ "kind": "type|value", "value": ... }] }`. - Form-A surface: new keyword `new` in lex/parse. Production `'(' 'new' <TypeName> <NewArg>+ ')'`. Round-trip preserved. - Checker: resolve `type_name` via type-scoped lookup (prep.1's mechanism) to its home module, find `new` def, check arg-kind against signature. - Two new diagnostics: `NewTypeNotConstructible`, `NewArgKindMismatch`. - `new` reserved as Form-A keyword — verified collision-free in workspace (grounding-check confirmed no existing def named `new`). - Drift pin: `term_new_round_trips`. **Spec:** docs/specs/2026-05-28-kernel-extension-mechanics.md § Iteration prep.2. **Whitepaper:** design/models/kernel-extensions.md § 2. The `new` term construct.
Brummel added this to the kernel-extension-mechanics milestone 2026-05-28 13:42:22 +02:00
Brummel added the feature label 2026-05-28 13:42:22 +02:00
Sign in to join this conversation.