How to interpret nested statements?

When we have nested statements, there are a few points to observe.

When we go from an embedding (enclosing) statement to its nested content, there is no special consideration: we follow the order from top to bottom.

The most critical part about nested statements is when we finish the nested content, and are ready to get back to the embedding (enclosing) statement. In some cases, we need to match the beginning of enclosing statements. In other words, after we execute line 9 of algorithm 2, we need to find the matching beginning of line 10, which is on line 3.

It is also important to find the matching end of an embedding statement. For example, when $x$ eventually becomes 3 to exit the outer loop in algorithm 2, we need to find the matching end of the outer prechecking loop that starts on line 3. Using indentation as a visual clue, we find that line 10 marks the end of this loop. Consequently, the next statement to execute (after line 3 and $x = 4$ ) is line 11.

Tak Auyeung 2007-09-14