An array programming language with a focus on tacit programming and expressivity
a caesura program is composed of tokens. a token may be:
- a literal scalar value (
floating
,integer
,boolean
,character
) - an identifier: a string matching
[^.,'():space:]+
. - a special operator: one of
.
,,
,'
,(
,)
,:=
.
a literal value, identifier or function application
in Caesura, functions may be monadic or dyadic, meaning they take either one or two arguments. Scalars and arrays can be seen as special cases of nonadic functions (zero-argument functions).
Caesura uses infix notation, and function application is done by adjoining the function and the value(s).
- a monadic function has its only argument on the right:
f x
(equivalent to lisp's(f x)
) - a dyadic function has a left argument and a right argument:
y f x
(equivalent to lisp's(f x y)
)
Note that it does not matter whether a
or b
are functions or data: the result of a f b
is equivalent to:
(lambda (x y) (f (a x y) (b x y)))
which is usually called a train in array languages.
If a
or b
only take one argument (or take none) then the left argument is discarded first, then the right.
While writing complex expressions, monadic or dyadic application can be enforced by the following operators: '
, .
-
the operator
'
enforces dyadic application of its right argument on its left argument and an additional argument on the right, and it has a precedence of 2. The expressiony'f x
is similar to lisp's(f x y)
. This syntax will enforce dyadic application even when the right argument is not present:y f
usually denotes applying the functiony
monadically to the argumentf
, buty'f
denotes partial application of the functionf
to the left argumenty
and evaluates to the monadic function(lambda (x) (f x y))
-
the operator
.
enforces monadic application of its left argument to its right argument, and it has a precedence of 1. the expressionf.x
is similar to lisp's(f x)
. crucially, ifx
is itself a function,.
can be interpreted as denoting function composition.
for reference, regular function application by adjacency has a precedence of 1.
a sequence of 1, 2 or 3 identifiers at the start of a line, followed by the operator :=
, followed by an expression that spans the rest of the line.
the following cases are possible:
a := (...)
:(...)
is evaluated and the result is bound to the identifiera
f g := (...)
where(...)
is an expression (possibly making use ofg
): binds tof
the monadic function whose value is(...)
when applied to the formal parameterg
.h f g := (...)
where(...)
is an expression (possibly making use ofg
andh
): binds tof
the dyadic function whose value is(...)
when applied to the formal parametersg
andh
.
symbol | monadic | dyadic |
---|---|---|
* |
square | multiplication (AND) |
+ |
identity | addition (OR) |
- |
arithmetic negation | subtraction |
~ |
1's complement (NOT) | mismatch (XOR) |
| |
--- | rotate |
name | type | explicit definition | tacit definition (explicit) | tacit definition (operators) |
---|---|---|---|---|
increment | monadic | inc x := 1 + x |
inc := 1 + -> |
inc := 1'+ |
successive diff | monadic | diff x := (1 | x) - x |
diff := (1 | ->) - -> |
diff := (1'|)'- |