Named Ground Expressions

A named expression appearing in a construct is equivalent to the ground expression it denotes.

Syntax

NamedExpression = "&" ExpressionName.

Purpose

Ground expressions appearing in a Refal Plus program may be given symbolic names (which syntactically are identifiers).

A symbolic name should be declared somewhere in the program by means of a declaration, and may denote:
  • A static ground expression.
  • A reference to an object.
  • A reference to a function.

If a name N denotes a ground expression Ge, the construct &N may be used instead of the expression Ge, since Ge is substituted for &N at compile time.

Since all references to objects as well as the objects are created when the program is compiled, loaded or executed, references cannot appear in the source program text as literals. Nevertheless, when an object is declared in a program, the references to the object are given a symbolic name, which may be used in the program for denoting the references.

Elimination of Symbolic Expression Names

If an identifier N is a symbolic name for a ground expression Ge, all occurrences of the name in a program may be eliminated by replacing each construct &N with Ge.

When describing context dependent restrictions and the syntax of the language, we assume the above transformation to have been done and, thus, symbolic expression names not to appear in the program. On the other hand, the transformed program text may well contain dynamic symbols.

Related concepts
Expression Names
Declarations
Result Expressions
Patterns
Hard Expressions
Constant Declarations
Restrictions on the Use of References to Functions