Lably
Skip to content

Concatenative programming language

Type of programming language

  • 2 min read
  • 3 chapters

Related on Lably

Through Function (mathematics), Expression (computer science) and Function composition

Example

For example, a nesting of operations in an applicative language like the following:

<span id="mwGA"></span><span class="nx" id="mwGQ">baz</span><span class="p" id="mwGg">(</span><span class="nx" id="mwGw">bar</span><span class="p" id="mwHA">(</span><span class="nx" id="mwHQ">foo</span><span class="p" id="mwHg">(</span><span class="nx" id="mwHw">x</span><span class="p" id="mwIA">)))</span>

...is written in a concatenative language as a sequence of functions:

x foo bar baz

Functions and procedures written in concatenative style are not value level, i.e., they typically do not represent the data structures they operate on with explicit names or identifiers. Instead they are function level – a function is defined as a pipeline, or a sequence of operations that take parameters from an implicit data structure on which all functions operate, and return the function results to that shared structure so that it will be used by the next operator.

The combination of compositional semantics with a syntax that mirrors such a semantic makes concatenative languages highly amenable to algebraic manipulation of programs; although it may be difficult to write mathematical expressions directly in them. Concatenative languages can be implemented efficiently with a stack machine, and are commonly present implicitly in virtual machines in the form of their instruction sets.

Sign in to keep reading

2 more chapters are free with a Lably account.

More in Computing and communication