Skip to content

Names, scope, and evaluation state

L resolves names before emitting Rust. Paragraph boundaries determine lexical scope; runtime activations determine when values are initialized and retained.

Quoted labels declare names. Create introduces a category or action, Define supplies a value or native definition, and "name" is value declares or assigns. The grammatical site and resolved value determine their meaning.

A statement publishes its declarations together, preserving separate coordinated targets and source order. Failure leaves existing bindings intact. Duplicate names in one namespace reject; private scopes may reuse spellings. Dependency retries do not reorder execution or pronouns. Forward local names reserve their spellings before lookup considers outer names or builtins.

docs/examples/binding-forward-member.l
Define App's "Label" as 1.
"scopeMarker" is 0.
Show App's Label.
Define App's "Label" as 2.
Show App's Label.
Show App's Label.

Fragment. Source: docs/examples/binding-forward-member.l.

Example evidence

Documentation excerpt reproducing TestParagraphBindingNativeTypeForwardMemberShadowsOuter source; binding/source-location evidence only, no runtime-before-assignment claim. static-inspection. Evidence guide.

Both indented Show App's Label occurrences bind the local Label, including the earlier occurrence. The final Show binds the outer Label. This binding witness does not authorize reading an unassigned runtime value: definite assignment is checked separately.

An ordinary paragraph uses its program or dictionary's environment. Four spaces before its first code line create a private scope. Parent bindings remain available unless shadowed; siblings cannot access each other's private declarations.

Public/Publicly publish only the selected declaration into the source unit's root, retaining its identity. They do not expose other declarations or a private owner's namespace. Each visibility modifier must target one declaration in its clause.

demo/paragraphs/local-shadowing.l
"message" is `outer`.
"message" is `inner`.
"count" is 7.
"enabled" is true.
Show message.
Show count.
Show enabled.
"message" is `second`.
Show message.
Show message.

Complete program. Source: demo/paragraphs/local-shadowing.l.

Example evidence

Sibling and enclosing source scopes preserve independent bindings. existing-witness-not-run. Evidence guide.

Each indented paragraph owns its message; the final Show reads the outer one. Expected stdout is inner7truesecondouter, without a newline.

demo/paragraphs/public-values.l (lines 1–3)
Publicly define "Greeting" as `public`.
Publicly define "Count" as 7.
Publicly define "Enabled" as true.

Fragment. Source: demo/paragraphs/public-values.l (lines 1–3).

Example evidence

First three declarations from the complete public-values runtime witness; following Dictionary and Show statements omitted. existing-witness-not-run. Evidence guide.

This private paragraph publishes Greeting, Count and Enabled. Later paragraphs in the complete example can name them. The excerpt omits the subsequent Dictionary and Show statements.

It, this and that bind the last subject defined in their original source paragraph. References within a statement use its incoming subject; coordinated declarations establish the next subject in source order. Mentioning an object or executing an action does not change it. A new paragraph has no inherited antecedent.

testdata/phase1/language/lang-06.l
Use IO's Print from `io` as "Print".
"message" is `canonical`.
Create "Worker" as a New Basic App.
The App Prints message.
Use Worker as "Job".
Start it.
Await Worker.
Await Job.
Show Job's Output.

Complete program. Source: testdata/phase1/language/lang-06.l.

Example evidence

Canonical LANG-06 pronoun, alias, repeated Await, and possessive Output program; frontend identity checks and native expected bytes are retained witnesses. existing-witness-not-run. Evidence guide.

Use Worker as "Job" makes Job the latest subject. Start it starts that same App; both Await statements address its invocation, and Job's Output reads finalized stdout. Expected output is canonical\n once.

testdata/phase1/n11-pronoun-crosses-paragraph/main.l
Use IO's Print from `io` as "Print".
"WorkerText" is `A`.
Create "Worker" as a New Basic App.
The App Prints WorkerText.
Await it.

Expected compilation failure. Source: testdata/phase1/n11-pronoun-crosses-paragraph/main.l.

Example evidence

Intentionally invalid N11 fixture: the new paragraph has no preceding pronoun subject; compile rejection before publication. existing-witness-not-run. Evidence guide.

This example rejects: Await it begins a paragraph without a subject. Use Worker explicitly and launch it before Await; changing the pronoun alone does not launch it.

Within an action definition, a pronoun may bind a preceding any parameter, as in Start's “Building any App and then Running it”. Ambiguous generic antecedents reject. Imports retain their own paragraph origins and cannot replace the caller's antecedent.

Worker's Output and it's Output select a member of the bound owner. Dotted names and imported aliases preserve that ownership: a missing member never falls back to a different outer owner. Members can be words, definitions or values; implicit Output/Error require an App.

demo/dictionaries/file-import/helpers.l
Create "LocalTools" as a Dictionary.
Define LocalTools's "Greeting" as `local hello|`.
Create LocalTools's "Display|-s|-ed|-ing|-er" for Showing any Text.

Fragment. Source: demo/dictionaries/file-import/helpers.l.

Example evidence

Companion vocabulary source for file-import; displayed as a source unit, not independently run. existing-witness-not-run. Evidence guide.

LocalTools's "Greeting" and LocalTools's "Display…" declare vocabulary members. The importing program aliases them before using unqualified names. These are not runtime Map entries.

Use existing as "Alias" retains the declaration's App identity, descriptor, members and signature. Imports use this relationship after checking exports. Aliases create no new process slot and confer no Main entry status. Cycles and unresolved targets reject. Dictionary private bindings stay in the dictionary; qualified members require an explicit alias for unqualified use.

Assignments write at their source positions. Every path continuing to a read must have assigned the value; exiting branches cannot reach the read. Conditional declarations supply no hidden initial value.

Assignment, arguments, returns and captures snapshot ordinary values and retain explicit Pointer identity. Short reads may borrow storage; Pointer shares targets without Rust lifetime annotations.

An action or Function declaration retains an environment for its activation. Captured assignments update that environment. Copies and aliases retain it until their last owner is released, even after the original name is rebound. Every capture must be assigned when the declaration executes. Static definitions retain definition-site bindings.

Source-word arguments evaluate once in the caller before entering the callee's environment. List/Map arguments retain their supplied contents. A callee can read an older captured List while receiving Text extracted from the caller's current List.

Output requires finalized capture; declaration, Build and assignment do not implicitly Await. Stored Output retains the bytes read from that invocation after reruns. App continuations get fresh local storage per invocation; repeated Await returns the same result without repeating effects. See execution.

demo/paragraphs/repeated-activation.l
Use IO's Print from `io` as "Print".
"message" is `Repeat`.
Create "Repeat" as a New Public Basic App.
The App Prints message.
Define "result" as Repeat's Output.
Show result.
Show result.
Use Repeat as "Worker".
Run Worker.
Await Worker.
Define "snapshot" as Repeat's Output.
Run Worker.
Await Worker.
Show snapshot.
Show Repeat's Output.

Complete program. Source: demo/paragraphs/repeated-activation.l.

Example evidence

Later invocation and retained scalar/output snapshots. existing-witness-not-run. Evidence guide.

Each Run/Await pair activates the indented continuation once, showing its local result twice. The outer snapshot retains the first invocation. Expected stdout is six Repeat\n lines; the counter-based witness additionally checks differing invocation bytes.

Unresolved names, ambiguous inflections, duplicate publication, cycles, inaccessible captures and incompatible assignments retain distinct diagnostics with original spans and expanded call sites. Internal Unknown storage never supplies a fallback value.

See scope planning, environments, member resolution, binding, visibility, publication and flow analysis. Tests cover bindings, publication, captures, activations, assignment, stored output, caller arguments and last-owner release.


Canonical source: docs/spec/names-and-scope.md.