Updated 2014-01-25 16:37:29 by PeterLewerin

The procedure until is not in the core, but you can define it yourself as follows:
proc until {cond code} {
    uplevel 1 [list while !($cond) $code]

See also control::do (in tcllib).

PL: The original rewriting of the command was like this:
list while !$cond $code

but that doesn't work since a cond value of, say, $i > 5 is rewritten as the condition argument !$i > 5 which will always evaluate to false (the ! operator has priority, and the result of evaluating it is either 1 or 0, which is never greater than 5). Other condition strings are likely to lead to other interesting errors.

Rewriting the command as
list while !($cond) $code

ensures that all of $cond is evaluated before negating the result.

This doesn't implement the usual meaning of until, which executes the code and then tests cond after.

DKF: The usual definition is typically expressed as a do-while loop, which is a form that puts the test last. When expressed condition-first, it is natural to expect the condition to be checked first...