A little comptime var during a runtime loop?

I was wondering if I can have this comptime var without an inline loop.
(My real loop is looping over the LSB’s of a u64, so an inline loop (0…64) seems a bit too much)

comptime var is_first: bool = true;

while (...)
{
    if (is_first)
        do_this_only_the_first_time();
    // do more
    is_first = false;
}

This seems like it’s might be an XY problem, why exactly do you want that to be inside the loop?

Wouldn’t it be cleaner to have it as:

do_this_only_for_the_time(item[0]);
while (...) {
    // do more
}

Yes true, but it would avoid a duplicate switch: one inside the loop and one outside.

(Edit: It is a (big monolithic) evaluation function of a chess position.)

Can we see the switch statement that would be duplicated, because that seems to be the problem you’re actually trying to solve?

Here the undressed loop.
For example you can see that in the bishop-case I want to do something only one time, not for each square.

inline for (Color.all) |us|
{
    inline for (PieceType.all) |piecetype|
    {
        var is_first: bool = true; // can we make this comptime?
        var bb_running = position.piece_bitboard(piecetype, us);
        while (bb_running != 0) : (is_first = false)
        {
            const sq: Square = pop_square(&bb_running); // get next square
            // Evaluate individual pieces on square.
            switch (piecetype.e)
            {
                .pawn => {},
                .knight => {},
                .bishop => 
                {
                    // if (is_first) reward bishop_pair    
                },
                .rook => {},
                .queen => {},
                .king => {},
            }
        }
    }
}

It is actually possible to do this with a different kind of loop:

	loop: switch(true) {
		inline else => |isFirst| {
			if(isFirst) do_this_only_the_first_time();
			// do more
			if(loopCondition) continue :loop false;
		},
	}

However if possible, I would recommend to keep using a normal loop.