Stack-oriented programming

Stack-oriented programming is a programming paradigm that relies on a stack (or multiple stacks) to manipulate data and/or pass parameters. Several programming languages fit this description, notably Forth, RPL, and PostScript. Stack-oriented programming languages operate on one or more stacks, each of which may serve a different purpose. Programming constructs in other programming languages need to be modified for use in a stack-oriented system.[1] Most stack-oriented languages operate in postfix or Reverse Polish notation. 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). The programming languages Forth, Factor, RPL, PostScript, BibTeX style design language[2] and many assembly languages fit this paradigm.

Stack-based algorithms manipulate data by popping data from the stack and pushing data to the stack. Stack manipulation operators govern how the stack manipulates data. To emphasize the effect of a statement, a comment is often used showing the top of the stack before and after the statement. This is known as the stack effect diagram. PostScript uses separate stacks for additional purposes, including variables, dictionaries, procedures, some typical procedures, and control flow statements. Analysis of the language model allows expressions and programs to be interpreted simply.

  1. ^ Luerweg, T. (2015). Stack based programming paradigms. Concepts of Programming Languages–CoPL’15, 33.
  2. ^ Oren Patashnik, Designing BibTeX styles (PDF)[dead link]

From Wikipedia, the free encyclopedia · View on Wikipedia

Developed by Nelliwinne