display | more...

In Forth, it is customary to explain a word's action by drawing the top of the stack before and after the word's execution. The two halves are separated by `--'. For instance,

   /MOD ( n1 n2 -- mod quot)
means that /MOD takes 2 numbers and returns `mod' (presumably n1 MOD n2, although the stack diagram only implies it if you know some conventions) and `quot' (presumably n1 DIV n2).

The space after the open-parentheses is important: it makes the entire stack diagram a legal Forth comment. Stack diagrams are often written in just this format at the definition of the word:

   : ABS ( n -- u)
       dup  < if negate then ;

Log in or register to write something here or to contact authors.