*** Welcome to piglix ***

Stack-oriented programming language


A stack-oriented programming language is one that relies on a stack machine model for passing parameters. Several programming languages fit this description, notably Forth, RPL, PostScript, BibTeX style design language and many assembly languages (on a much lower level).

Stack-oriented languages operate on one or more stacks, each of which may serve a different purpose. Thus, programming constructs in other programming languages may need to be modified for use in a stack-oriented system. Further, some stack-oriented languages operate in postfix or Reverse Polish notation, that is, any arguments or parameters for a command are stated before that command. For example, postfix notation would be written 2, 3, multiply instead of multiply, 2, 3 (prefix or Polish notation), or 2 multiply 3 (infix notation).

Assume a postfix stack-based language, like PostScript. To understand how stack-orientation works, in calculating an expression such as 2 3 mul, consider a simple thought experiment.

Imagine standing at the end of a conveyor belt (the input), onto which have been placed (in sequence) plates marked 2, 3, and mul. One can take the plate at the end of the conveyor (2), but cannot see or take further plates from the conveyor until something is done with the plate just taken. The only way plates can be stored is in a stack, and plates can only be added or removed from atop the stack, not from the middle or bottom. One also has a supply of blank plates (and a marker), and can discard plates (which is permanent). Try to perform the calculation.

Human stack.svg


...
Wikipedia

...