There were several programming languages explicitly based on a stack. The simplest one was used by HP calculators. These calculators could do fairly complex math, but it took practice. To add 1 and 2 together, you would type 2, hit enter, which would put that value on the stack. Next, 1 then enter, and tnat goes on top of the stack. Finally, you hit the plus key, which will then pull the top number off the stack (1) then add the second number off the stack (2), and put the answer (3) back on the stack. These calculators had crazy complicated functions (like matrix math) that could have you placing 20 numbers on the stack (in the right order of course).
The Forth language used a stack in a similar way, but as a general programming language. You could define functions and thet would grab values off the stack. So CIRCLE might grab 3 values, x y, and radius, to draw a circle on the screen. It was confusing as hell to write code, but it ran quickly. A derivative of forth, Postscript, is still used in laser printers. Look at a Hello World for postscript and you’ll see the stack used in all its glory.
Latest Answers