prep.2 — Term::New construct ((new T args...) Form-A keyword) #32
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Second iteration of the
kernel-extension-mechanicsarc. Depends on prep.1 for the type-scoped resolution it relies on.Goal. Add a new term construct
(new T arg1 arg2 ...)that calls thenewdef 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-ctorfor named-data-ctor ADT construction.Scope (from spec § Iteration prep.2):
Term::New { type_name: TypeName, args: Vec<NewArg> }withNewArg = NewArg::Type(Type) | NewArg::Value(Term)inailang-core/src/ast.rs. Serialised as{ "t": "new", "type": "...", "args": [{ "kind": "type|value", "value": ... }] }.newin lex/parse. Production'(' 'new' <TypeName> <NewArg>+ ')'. Round-trip preserved.type_namevia type-scoped lookup (prep.1's mechanism) to its home module, findnewdef, check arg-kind against signature.NewTypeNotConstructible,NewArgKindMismatch.newreserved as Form-A keyword — verified collision-free in workspace (grounding-check confirmed no existing def namednew).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
newterm construct.