|
The concatenative or stack-based programming languages are ones in which the concatenation of two pieces of code expresses the composition of the functions they express. These languages use a stack to store the arguments and return values of operations. A programming language is an artificial language that can be used to control the behavior of a machine, particularly a computer. ...
This article is about the string operation of computer programming. ...
In mathematics, a composite function, formed by the composition of one function on another, represents the application of the former to the result of the application of the latter to the argument of the composite. ...
Simple representation of a stack In computer science, a stack is a temporary abstract data type and data structure based on the principle of Last In First Out (LIFO). ...
The most widespread concatenative language is the page description language PostScript, a restricted version of which is used in PDF. However, Postcript code are usually generated by programs written in other languages. Other well-known concatenative languages include Forth[1][2], and the RPL used on Hewlett-Packard HP-28 and HP-48 scientific calculators. For the literary term, see Postscript. ...
PDF is an abbreviation with several meanings: Portable Document Format Post-doctoral fellowship Probability density function There also is an electronic design automation company named PDF Solutions. ...
Forth is a structured imperative stack-based computer programming language and programming environment. ...
The RPL programming language (RPL meaning reverse Polish LISP or, alternatively, ROM-based procedural language) is a handheld calculator system and application programming language used on Hewlett-Packards engineering graphing RPN calculators of the HP-28, HP-48 and HP-49 series. ...
The Hewlett-Packard Company (NYSE: HPQ), commonly known as HP, is a very large, global company headquartered in Palo Alto, California, United States. ...
The HP-28s were two graphing calculators produced by Hewlett-Packard from 1987 to 1992. ...
The HP-48 is a series of graphing calculators produced by Hewlett-Packard (HP) from 1990 until 2003, using Reverse Polish notation (RPN). ...
The RPL used on Hewlett-Packard HP-28 and HP-48 scientific calculators is a concatenative garbage-collected language that has been popular amongst generations of electrical engineers. Other concatenative languages include Joy, Cat, and Factor[3][4], [5][6]. The RPL programming language (RPL meaning reverse Polish LISP or, alternatively, ROM-based procedural language) is a handheld calculator system and application programming language used on Hewlett-Packards engineering graphing RPN calculators of the HP-28, HP-48 and HP-49 series. ...
The Hewlett-Packard Company (NYSE: HPQ), commonly known as HP, is a very large, global company headquartered in Palo Alto, California, United States. ...
The HP-28s were two graphing calculators produced by Hewlett-Packard from 1987 to 1992. ...
The HP-48 is a series of graphing calculators produced by Hewlett-Packard (HP) from 1990 until 2003, using Reverse Polish notation (RPN). ...
The Joy programming language is a purely functional programming language that was produced by Manfred von Thun of Latrobe University in Melbourne, Australia. ...
The Cat programming language is a functional stack-oriented programming language inspired by the Joy programming language. ...
Factor is a dynamically typed concatenative programming language whose design and implementation is led by Slava Pestov. ...
The concatenative languages may be regarded as a language family, similar to the Lisp languages. As with the Lisps (including Scheme), there are strong "family resemblances" within the group. However, there are also major differences in the design, implementation, and purposes of these languages. RPL and many versions of Forth itself are targeted at small and embedded devices; likewise PostScript is targeted largely at a specific type of device, namely printers. Other concatenative languages, however, are general-purpose or research-focused, as with Joy and Cat. âLISPâ redirects here. ...
The Joy programming language is a purely functional programming language that was produced by Manfred von Thun of Latrobe University in Melbourne, Australia. ...
The Cat programming language is a functional stack-oriented programming language inspired by the Joy programming language. ...
History and description Forth was the first language of this sort, but Joy was the first language to call itself concatenative. The creator of Joy, Manfred von Thun, has written much about concatenative theory. Forth is a structured imperative stack-based computer programming language and programming environment. ...
The Joy programming language is a purely functional programming language that was produced by Manfred von Thun of Latrobe University in Melbourne, Australia. ...
The Joy programming language is a purely functional programming language that was produced by Manfred von Thun of Latrobe University in Melbourne, Australia. ...
Formally speaking, a programming language is concatenative (and not applicative) when:[citation needed] Applicative refers to a language paradigm for classifying computer programming languages. ...
- The elementary well-formed expressions of the language are monadic functions of one argument and one return value.
- If X and Y are well-formed expressions, then the concatenation of X and Y is well-formed.
- If Z is the concatenation of X and Y, then the value of Z is the composition of the values of X and Y.
In this definition, there is no mention of the stack; however, all concatenative languages do use a stack, as it is the most straightforward way to pass data from one operation to the next. The term "concatenative" is not universally accepted as a particularly useful term, with many users of these languages preferring to call them "stack-based". An expression in a programming language is a combination of values and functions or procedures, interpreted according to the particular rules of precedence and of association for a particular programming language, which computes and then returns another value. ...
In mathematics, a unary operation is an operation with only one operand. ...
Operators or functions in these languages are usually referred to as words, and this article will refer to them as such.
Postfix notation Code in concatenative languages resemble the postfix notation or reverse Polish notation (RPN) form of arithmetic. Arguments, or code that produces arguments, comes first, followed by the words that use those arguments. Literals, such as numbers, place values on the stack; other words may consume some items from the stack and produce others. Reverse Polish notation (RPN) , also known as postfix notation, is an arithmetic formula notation, derived from the Polish notation introduced in 1920 by the Polish mathematician Jan Łukasiewicz. ...
Postfix notation is a mathematical notation wherein every operator follows all of its operands. ...
An example: 2 3 + . In Forth and Factor, this is a valid program: 2 and 3 are literals, words that simply push a value onto the stack. + is a mathematical operator; it removes the top two values from the stack and pushes their sum. Finally, the . (dot) operator removes the top value and prints it to the display. Thus, this program will print the number 5.
Flow control In order to be Turing-complete, a language must have some means of flow control -- the ability to make branches or choices based on the value of an expression. Concatenative languages implement flow control in different ways. Contrast the following examples in Forth and Factor: In computability theory a programming language or any other logical system is called Turing-complete if it has a computational power equivalent to a universal Turing machine. ...
The flow control mechanism is used for controlling the flow of data in a network under well-defined conditions, while congestion control is used for controlling the flow of data when congestion has actually occurred . ...
= IF 23 ELSE 17 THEN = [ 23 ] [ 17 ] if Both examples do the same thing: compare the top two items on the stack; if they are equal, the value 23 is left on the stack; if they are not equal, the value 17 is left. In Forth, the word IF is special; it causes the code prior to the ELSE to be executed if the condition is true, or the code after the ELSE if it is false. In Factor, the word if is just another function; it consumes the condition and two quotations, or quoted code fragments; it executes the first quotation or the second based on whether the condition is true. The ifelse operator in PostScript is similar. The formalization of code quotations, a feature ultimately inherited from Lisp, distinguishes the later concatenative languages such as Factor and PostScript from earlier ones such as Forth. Words that operate on quotations are sometimes called combinators. Lisp is a family of computer programming languages with a long history and a distinctive fully-parenthesized syntax. ...
This article is about a topic in theoretical computer science, and is not to be confused with combinatorial logic, a topic in electronics. ...
Definitions and parsing words The concatenative languages differ widely in the syntax used to define new words. The following pieces of code in Cat, Forth or Factor, and Joy all do the same thing: define a new word called add100 which adds 100 to the value on the top of the stack. define add100 { 100 + } : add100 100 + ; DEFINE add100 == 100 + . In each case, the body of the definition is the same: the words 100 +. What differ are the parsing words used to tell the language that a definition is taking place. Parsing words are somewhat analogous to keywords in C or special operators in Lisp: rather than expressing operations on the stack, they control how the parser deals with the following words. It is possible to define new parsing words. This ability gives concatenative languages their equivalent of Lisp macros: programmers can define new syntax.
Stack effect Concatenative programming makes use of the notion of the stack effect of a word. A word's stack effect is a description of what values are consumed from the stack, and what values are left on the stack, when the word is executed. Typically, a word will have a consistent stack effect: it will always consume the same number of arguments and leave the same number of results.
External links |