Skip to content

References

Benedict Albrecht edited this page Jun 1, 2026 · 4 revisions

References

References substitute reusable object patterns into other definitions. The referenced object's variables are merged into the parent — without creating a child relationship.


How References Work

graph LR
    FUNC["<b>function</b><br/>&lt;-{string, int}-&gt;"] -.->|"merges variables"| STR["<b>string</b><br/>&lt;&lt;var&gt;&gt;"]
    FUNC -.->|"merges variables"| INT["<b>int</b><br/>&lt;&lt;var&gt;&gt;"]

    style FUNC fill:#4a90d9,color:#fff
    style STR fill:#e67e22,color:#fff
    style INT fill:#e67e22,color:#fff
Loading

Key: Referenced objects do not appear as children. Only their variables are merged.


Syntax

<-{ refA, refB ... }->

References cannot be empty.


Example

Define reusable parameter types:

<:string:> string <<var>> <:>
<:int:> int <<var>> <:>

Use them as references in a function definition:

<:function:> function <<name>> ( <-{string, int}-> ) { <---> } <:>

The function can accept string or int parameters. The <<var>> variable from each referenced object is added to the function's variable set.


Behavior

When a reference is used, the parser attempts to match the referenced object's pattern at that position in the input. If a match is found:

  1. The referenced object's variables are captured and merged into the parent object
  2. The referenced object itself does not appear as a child in the dependency tree
  3. Multiple references are tried in order — the first matching definition wins

This makes references ideal for reusable patterns like type annotations, parameter lists, or modifier keywords that need to contribute variables without creating structural nesting.


vs. Sub-bodies

Feature Reference <-{}-> Sub-body <--->
Creates children
Merges variables
Appears in tree

Next: Or Statements — Matching one of several alternatives.

Clone this wiki locally