2021-06-04
The grammar of TAO includes the following rule (in BNF):
"`" <any> <operator> ::=
Where any
is any printable Unicode character.
The operator
is a very simple, yet very versatile
concept, which captures the essence of many syntactical constructs. It
has 2 basic roles in TAO:
Escape mechanism for the 3 meta symbols of the grammar,
i.e. [
, ]
, and `
(the operator
symbol itself).
Extension mechanism for future notations based on TAO as well as
for custom ad-hoc notations – either community-built notations that
might become standard or limited-use internal notations. There is thus a
risk associated with abuse of this mechanism. In the spirit of TAO, the
use of operator
s should be kept to a minimum.
Furthermore, an important property of the operator
is
that a single operator
meta symbol `
introduces two annotation
insertion points at the same
depth in the syntax tree – on either side of the operator. This enables
slightly more compact notations than could be achieved otherwise.
The property is also where operator
gets its name from.
It is however a more primitive and lower-level construct than a
programming language operator – a programming language built on top of
TAO could use it to represent operators.
What follows from the grammar definition, but is perhaps worth noting, is that operators are always single-character. A possible way to model a multi-character high-level operators could be to use a low-level operator for “quoting” these, e.g.
a`.<=>`.b
Here `. is the low-level quoting operator and <=>
is the high-level multicharacter quoted operator.
A less generic, but a more compact way could be (colored for clarity):
a`<=>[b]
Here `<
could be a low-level
operator that introduces a class of high-level operators. The annotation
that follows it – =>
– determines a
specific high level operator
(<=>
). What follows is a tree
that contains the right-hand-side argument to the high-level
operator.
A programming language built in the true spirit of TAO however would avoid both of the above solutions. A better one would not use operators in this case at all, e.g.:
[a]<=>[b]
But that’s a story for another time.