Skip to content

Sub bodies

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

Sub-bodies

Sub-bodies define where child objects can appear within a parent object, creating hierarchical nesting.


How Sub-bodies Work

graph TD
    subgraph "<--->  Default Sub-body"
        CLASS1["<b>class</b>"] <-->|"both-sided<br/>dependency"| FUNC1["<b>function</b>"]
    end

    subgraph "<-function->  Typed Sub-body"
        CLASS2["<b>class</b>"] ---|"no dependency<br/>on child"| FUNC2["<b>function</b>"]
        FUNC2 -->|"depends on<br/>parent"| CLASS2
    end

    style CLASS1 fill:#4a90d9,color:#fff
    style FUNC1 fill:#7b68ee,color:#fff
    style CLASS2 fill:#4a90d9,color:#fff
    style FUNC2 fill:#7b68ee,color:#fff
Loading

Basic Sub-body <--->

Accepts any child object. Creates a both-sided dependency between parent and child.

<*{}*> { <---> } <*>
<:class:> class <<name>> () { <---> } <:>

Typed Sub-body <-name->

Accepts only the named object type. Only the child depends on the parent - not the other way around.

<:class:> class <<name>> () { <-function-> } <:>
<:function:> function <<name>> () { <---> } <:>

This allows loosely coupled structures - e.g., functions within a class where the class doesn't depend on its functions.


Dependency Comparison

Sub-body Accepts Parent → Child Child → Parent
<---> Any object
<-name-> Named type only


In Practice

The Basics grammar uses both types:

Object Sub-body Effect
class <-function, class, refference, variable-> Typed - only these four types can appear inside a class. The class does not depend on its children.
function <-function_-> Wildcard (underscore) - any object type can appear inside a function body.

In the Test_Repo, class C1 contains function F1, function F2, and several variable objects. These are allowed by the typed sub-body. If the source code contained an import inside the class, it would not be parsed because import is not listed.

See Repo Analysis for the full parsed object trees.


Next: References - Substituting objects into other definitions.

Clone this wiki locally