Control Structures

Control structures determine the flow of a program; they dictate the order in which code is executed. Some familiar examples include loop and if-statement variations. In Clojush, control structures can be manipulated from both the CODE and EXEC stack. As such, instruction names will begin with either code_ or exec_. For instance, there are two variations of the do*range instruction: exec_do*range and code_do*range. The difference between these instructions is the type of stack on which they are pushed.

Some examples of the more commonly used control structures include exec_noop, exec_do*count, exec_while, exec_do*while, exec_if, and exec_do*times. All of the instructions mentioned exist for the code stack as well. Descriptions of most of the control instructions can be found here. While this catalog is not syntactically up to date, the behavior of many of the current Clojush instructions conform to the descriptions listed.