To understand why this works you need to understand the system of stack evaluation that is at the core of Ripley. Ripley has two stacks, the execution stack and the operand stack. Both stacks start empty. When a program is evaluated it is placed into the execution stack. So in our example the stacks start as:
Operand Stack: Execution Stack: 1.0 2.0 add print
The interpreter gets the first item on the execution stack and executes it. In this case it's a simple value '1'. In the case of simple values it pushes the value onto the operand stack. So after the first evaluation the stacks look like this:
Operand Stack: 1.0 Execution Stack: 2.0 add print
The same thing happens with the '2'.
Operand Stack: 2.0 1.0 Execution Stack: add print
The next item is a literal 'add'. The interpreter looks literals up in the dictionaries and then executes the result. 'add' is a registered operand in the system dictionary. (More about dictionaries in a bit.) The 'add' operand pops two elements off the operand stack, adds them together pushes the result back onto the operand stack. After the evaluation of 'add' the stacks look like this:
Operand Stack: 3.0 Execution Stack: print
Ripley then evaluates the 'print' literal, which is another operator found in the system dictionary. Print pops the operand stack and prints the result out to STDOUT. It does not push anything back onto the operand stack. After '3' is printed out by the 'print' operator the stacks look like this:
Operand Stack: Execution Stack:
Next we do a little more math.