language · keyword ·

while

Repeat while a condition is true

complete-programcpukeywordloopsyeho

Use while when the stopping condition is more natural than a known collection or numeric range.

while

Status: stable

Positive

Use while when the stopping condition is more natural than a known collection or numeric range.

cpu · complete-program · type checked

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")
}
project.mech
package = "tests.coreEdition.positive"
Notes and source

The condition must be bool.

Update the condition's inputs inside the loop unless an external event owns progress.

yeho/parser_statements.cpp parseWhileStatement; Kyber loop runtime fixtures