CHIP: Bounded Looping Operations
The Bitcoin Cash virtual machine is strictly limited to prevent maliciously-designed transactions from requiring excessive resources during transaction validation.
Loops were originally excluded from this design on the mistaken assumption that they risk consuming excessive validation resources. In reality, a small number of VM operations make up the majority of resource usage during transaction validation, and any implementation of bounded loops can be many orders of magnitude faster than the most pathological VM bytecode constructions.
Introducing this basic control flow structure would make BCH contracts significantly more powerful and efficient.
The precise implementation is influenced by the BEGIN ... UNTIL
indefinite loop construction in the Forth programming language (upon which the rest of the Bitcoin Cash VM is based). This particular construction offers maximal flexibility: definite loops can be easily emulated with these indefinite loops, but indefinite loops could not be emulated with definite loops.
You can find the full specification on GitHub:
Review and feedback are deeply appreciated. Thanks!