"Activity is the essence of substance in general" (Leibniz).
"But only this is to be called 'interpretation': substituting one expression of the rule for another" (Wittgenstein, Philosophical Investigations).
Evaluation
Semantics
The evaluation of an expression consists of its substitution by the right-hand side of its substitution expression, if it exists. In turn, other substitution expressions may appear in the right-hand side, which in turn are evaluated, in a cascading process.
When there is no substitution specification for an expression, then it remains unchanged or, in other words, the expression is self-evaluating (evaluates as itself). Such an expression is said to be "terminal".
Syntax
There is no explicit operator to specify that an expression be evaluated, since, by default, every expression is evaluated automatically.
Justification
Evaluation is a simple, but very powerful mechanism for applying previously defined substitution expressions.
Non-Evaluation
Semantics
Not to evaluate an expression is to self-evaluate it, i.e., the result is the same expression, even if there is a substitution expression for it previously defined.
Syntax
x° // do not evaluate x or self-evaluate x
Justification
The "non-evaluation" is a mechanism that allows us three things:
Refer to expressions, as specified (self-expressions).
Facilitate deferred evaluation processes.
Reference the name as a container or the equivalent of address.
The fact that an operator is used for the opposite operation is motivated by the higher frequency of occurrence of "evaluation" than "non-evaluation".
Examples
(x = 7)
(x = x+1) // ev. x=8
The first x is not evaluated and the second one is.
The "non-evaluation" is used to perform the deferred evaluation, also called offline evaluation.
The normal evaluation (online) is the one that is performed immediately during a process. In deferred evaluation (offline), the expression is not evaluated immediately, but when it is referred to in a later step.
Deferred evaluation is a very powerful mechanism that allows us to define parameterized expressions, which are subsequently evaluated with the values of the parameters (arguments) at each point in time. This means integrating these definitions as any other expression within a dynamic environment.
Examples:
(y° = (x x x+1 x+2)°) // ev. (y = (x x x+1 x+2))
(x = 0)
y // ev. (0 1 2)
(x = 5)
y // ev. (5 6 7)
As can be seen, each time y is referenced, the expression (x x x+1 x+2) is evaluated with the value of x at each point in time.
In MENTAL there is no equivalent of memory addresses, but only names of expressions in abstract space. These names play an analogous or equivalent role to addresses. The evaluation of the names are the corresponding contents. In general:
The expression x° is the "container" (or "continent") of name x.
The expression x refers to the "content" or value of x.
In the expression (x° = a), x is the container and a the content.
Examples:
(x = abc)
x\2 // ev. b (refers to the content of the second position of x)
(x\2)° // ev. x\2 (refers to the second position of x)
(x\2 = u) // (replaces the contents of the second position of x with u)
x // ev. auc
(x = {a b c}
x↓ // ev. a b c (open expression)
(x↓ = u) // (replaces the content of x by u)
x // ev. {u}
Recursion
It is possible to specify higher-order deferred evaluations. The expression x°° indicates that there is a doubly deferred evaluation, i.e., two "uses" of x are required for it to be evaluated. Analogously for x°°°, x°°°°, etc.
Examples:
(x = (123+4)°°°) // ev. (x = (123+4)°°)
(y = x) // ev. (y = (123+4)°)
(z = y) // ev. (z = 123+4)
(u = z) // ev. (u = 127)
(x = 2)
(y = (3*x + 1)°°) // ev. (y = 3*x + 1)°)
(z = y) // ev. (z = 3*x + 1)
(u = z) // ev. (u = (3*2 + 1)) ev. (u = 7)
Remarks
The "non-evaluation" operator can be applied to part of an expression and even to an operator. In the latter case we refer to the operator as a symbol, so the operation is not performed and in the result of the evaluation the operator is kept.
Examples:
(a = 3)
(a +° 2) // ev. 3+2
(a = 1)
(b = 2)
(a + (a *° b)) // ev. (1 + 1*2)
(x = 3)
(x + (y*x)°) // ev. (3 + y*x)
(a = 1)
(b = 2)
(a (a b)° b) // ev. (1 ab 2)
(x = 44)
(x =° 123) // ev. x=123
(substitution does not occur)
x // ev. 123
(deferred substitution occurs, when reference is made to x)
Normally digits and characters are terminal expressions (they are self-evaluating), but the language does not impose any restrictions. Therefore an expression like 3=7 would be possible, so that if we have (x = 3231), then x would evaluate to 7271.
The "non-evaluation" operator applied to a compound expression is equivalent to applying it to each of its components and at all levels. For example,
If hierarchical "non-evaluation" operators are specified, only the outermost one acts. For example,
(x = 7)
(y = 4)
(z° = (x° + 1 + y)°) // ev. (z = (x° + 1 + y)
(u = z) // ev. (u = (x + 1 + 4)) ev. (u = x+5)
u // ev. 12
The expression x(°°) indicates self-applying "non-evaluation" to the "non-evaluation" operator itself. In this case, the "non-evaluation" affects the "non-evaluation" operator itself, but not x. The result is x (evaluated) together with the "non-evaluation" operator. For example,
(x = 3)
(2*x + a)(°°) // ev. (6 + a)°
Evaluation could affect a substitution expression. Examples: