title | layout | prev | prev_url |
---|---|---|---|
Introduction |
default |
Table of Contents |
toc.html |
This is the Concat programming language specification. To understand this document, you need to understand the purpose of the different styles. This paragraph is body text.
Text that looks like this is code.
This is a detail of the implementation the author plans to write, and not actually part of the language.
In the top right is a link to the table of contents. At the bottom are links to the previous and next sections.
Concat is a Python-based, concatenative, stack-based, point-free programming language.
'Hello from Concat' print
Expressions are postfix to match the concatenative style. There is a dedicated
negation operator (-)
to remove the need for parentheses.
b (-) b 2 ** 4 a * c * - sqrt + 2 a * / # (-b + sqrt(b**2-4*a*c))/(2*a)
But wait a second! There are no variable names. All objects exist on the stack (except named functions). Here is the same example as a function with no variable names.
def quadratic_root:
swap (-) dup 2 ** stash stash
4 * preserve(*) unstash - sqrt unstash + swap pop
swap 2 * / return
What's with the lack of formal parameters? There are none - that's what makes
the language point-free. Instead of formal parameters, the stack is implicitly
passed (see Function Calls). Also, what's swap
, dup
,
(un)stash
, pop
and preserve
? preserve
is an
operator modifier, and the others are
stack modifiers.
The implementation I plan to write will translate directly into Python, meaning code from both languages should interop perfectly.