Refal Plus result expressions are, in a sense, an analog to the well-known arithmetic expressions. They may contain constants, variables and function calls, and are used for producing new ground expressions from constants and variable values.
<Add <Mult sX sY> 3>
<Mult sX <Add sA sB>>
<Add <Mult sX sA> sB>
Result expressions, similarly to arithmetic expressions in other languages, are used for producing new values from other ones. Thus, a result expression is evaluated by replacing all its variables with their values and evaluating all function calls. If there are nested function calls, the inner calls are evaluated before the surrounding ones.
{V1 = Ge1, ..., Vn = Gen}will be used for denoting the environment in which the variables V1, ..., Vn have the respective values Ge1, ..., Gen.
As can be seen from the above, the representation of arithmetic expressions by result expressions is rather clumsy. Nevertheless, it does have certain advantages.
The point is that the choice of one or another notation is determined by the nature of the objects to be dealt with, as well as by the set of operations to be applied to the objects.
It is reasonable to choose the notation in such a way that the most frequently used operations be denoted as concisely as possible. But the most succinct notation is, certainly, no notation at all, i.e. an empty place!
As far as arithmetic expressions are concerned, we have two basic operations: addition and multiplication. One of the operations may be denoted by empty place, and the common practice is to omit the operator of multiplication.
On the other hand, the principal data dealt with by Refal Plus are ground expressions, rather than numbers. Since the basic operations on ground expression are the concatenation of two expressions and the enclosing of an expression in parentheses, it is for these operations that the syntax of Refal Plus provides a very concise notation.
Re' Re"which means that Re' and Re'' are to be evaluated and the values returned are to be concatenated to produce the result of the whole expression. Thus, if the evaluation of Re' and Re'' results in returning ground expressions Ge' and Ge'' respectively, the ground expression Ge' Ge'' is returned as the result of evaluating Re' Re".
( Re )which means that Re is to be evaluated and the value returned is to be enclosed in parentheses to produce the result of the whole expression. Thus, if the evaluation of Re results in returning a ground expression Ge, the ground expression ( Ge ) is returned as the result of evaluating ( Re ) .
sX '+' sY (eZ)in the environment {sX = 25, sY = 36, eZ = A (B C) D} is the ground expression
25 '+' 36 (A (B C) D)