Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

While Loops

Sydrogen supports While loops.

Basic syntax:

While (Condition)
{
    // body
}

Example:

Int I = 0;

While (I < 10)
{
    I = I + 1;
}

The condition is evaluated before every iteration.

Nested Loops

While loops can be nested:

Int I = 0;
Int V = 0;

While (I < 100)
{
    V = 0;

    While (V < 100)
    {
        V = V + 1;
    }

    I = I + 1;
}

Nested loops are compiled to native control flow.

Normal Sydrogen While loops execute on one thread.

The compiler using multiple CPU cores for semantic analysis does not make the generated loop multicore. The compiler cannot simply yell "parallel!" at a loop and hope for the best.


← Previous Next →