# static

Attach a member to the type

Last updated: 2026-09-09

Package: language | Status: stable

Tags: complete-program, cpu, data, keyword, yeho

Use a constructor to establish valid starting data, an instance method for behavior that belongs to one value, and static only when no instance state is needed.

```yh
static
```


## Static plain data method

Use a constructor to establish valid starting data, an instance method for behavior that belongs to one value, and static only when no instance state is needed.

Verification: type checked

```yh
thing pair
{
    int left
    int right
}

class pairMath
{
    static Make(int left, int right) returns pair
    {
        pair value = pair()
        value.left = left
        value.right = right
        return value
    }

    static Sum(pair value) returns int
    {
        return value.left + value.right
    }
}

pair value = pairMath.Make(20, 22)

if pairMath.Sum(value) == 42
{
    Console.Log("static-plain-data-method-ok")
}



```

Save this beside start.yh as project.mech:

```toml
package = "tests.compiler.kyber.staticPlainDataMethod"
version = "0.1.0"
backend = "kyber"
osTarget = "windows"
archTarget = "x64"
selfContainedApp = false




```

Extract the example archive beside the yeho and dolphin checkouts. This example requires those source dependencies and a current developer compiler.

```sh
./yeho/build/dolphin-metal/yehoc ./api-examples/word--static/complete --backend cpu-oracle -o /tmp/yeho-example
/tmp/yeho-example
```


Stored constructor values follow declaration order for the current value-data ABI.

Class dispatch remains a separate oracle-only boundary even though plain-data constructors and direct admitted calls run through Kyber.

Source: yeho/tests/compiler/kyber/plain-data-constructor/start.yh; tests/compiler/kyber/legalized-call-forms/start.yh

AI training permission: https://demonhunterlabs.com/ai-use
