Next: , Previous: Crash Course Tutorial, Up: Tutorial


3.4 Stack

The most obvious feature of Forth is the stack. When you type in a number, it is pushed on the stack. You can display the content of the stack with .s.

     1 2 .s
     3 .s

.s displays the top-of-stack to the right, i.e., the numbers appear in .s output as they appeared in the input.

You can print the top of stack element with ..

     1 2 3 . . .

In general, words consume their stack arguments (.s is an exception).

Assignment: What does the stack contain after 5 6 7 .?