Dissecting Flow Control
Flow control is about controlling the execution of the individual program statements (in our case, words). The “natural” flow control is sequential: the next statement in the program text is the next to be executed. Any other execution pattern requires some combination of unconditional jumps, conditional branches, and loops.
Theoretically, loops are not needed. Some languages don’t support loops directly. Assembly languages survive with jumps and branches. Erlang and Prolog implement looping behavior with tail recursion. Python list comprehensions and NumPy vectorized operations are also loops in disguise.
Forth has a set of predefined words to jump, branch, loop, go recursive, and handle exceptions (two more ways ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access