# while

Repeat while a condition is true

Last updated: 2026-09-09

Package: language | Status: stable

Tags: complete-program, cpu, keyword, loops, yeho

Use while when the stopping condition is more natural than a known collection or numeric range.

```yh
while
```


## Positive

Use while when the stopping condition is more natural than a known collection or numeric range.

Verification: type checked

```yh
thing point
{
    int x
    int y

    point(int x, int y)
    {
        this.x = x
        this.y = y
    }

    Sum() -> int
    {
        return this.x + this.y
    }
}

Add(int left, int right) -> int
{
    return left + right
}

point value = point(2, 3)
int total = 0
for i from 0 < 4
{
    total = total + i
}

int iterations = 0
while iterations < 2
{
    iterations = iterations + 1
}

if value.Sum() == 5 and Add(total, iterations) == 8
{
    Console.Log("core-edition-ok")
}
else
{
    Console.Log("core-edition-failed")
}

```

Save this beside start.yh as project.mech:

```toml
package = "tests.coreEdition.positive"

```

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--while/complete --backend cpu-oracle -o /tmp/yeho-example
/tmp/yeho-example
```


The condition must be bool.

Update the condition's inputs inside the loop unless an external event owns progress.

Source: yeho/parser_statements.cpp parseWhileStatement; Kyber loop runtime fixtures

AI training permission: https://demonhunterlabs.com/ai-use
