Some stack-oriented languages may use multiple stacks for different purposes; for example, PostScript uses separate stacks for variables, dictionaries, procedures, some typical procedures, and control flow statements.
Analysis of the language model allows expressions and programs to be interpreted simply.
At the end of a conveyor belt (the input), plates marked 2, 3, and mul are placed in sequence.
For example, the basic Forth stack operators are described: The fib function below is described: It is equivalent to preconditions and postconditions in Hoare logic.
Both comments may also be referenced as assertions, though not necessarily in the context of Stack-based languages.
The way variables are implemented in stack-oriented languages such as PostScript usually involves a separate, specialized stack which holds dictionaries of key-value pairs.
A difference exists between /x and x – the former is a data object representing a name, and x stands for what is defined under /x.
A procedure in a stack-based programming language is treated as a data object in its own right.
Dictionaries provide a means of controlling scoping, as well as storing definitions.
To examine a Fibonacci number program in PostScript: A recursive definition is used on the stack.
As there exist anonymous procedures, flow control can arise naturally.
The way such programs are written facilitates being interpreted by machines, which is why PostScript suits printers well for its use.
While the ability to shadow by overriding inbuilt and other definitions can make programs hard to debug, and irresponsible use of this feature can cause unpredictable behaviour, it can simplify some functions greatly.
For example, in PostScript use, the show page operator can be overridden with a custom one that applies a certain style to the page, instead of having to define a custom operator or repeat code to generate the style.