Download free books at BookBooN.com
An Introduction to Relational Database Theory
35
Values, Types, Variables, Operators
Each annotated component in Figure 1 is an example of a certain language construct. The annotation
shows the term used for the language construct and also the term for the concept it denotes. Honouring
this distinction at all times can lead to laborious prose. Furthermore, we don’t always have distinct terms
for the language construct and the corresponding concept. For example, there is no single-word term for
an expression denoting an argument. We can write “argument expression” when we need to be absolutely
clear and there is any danger of ambiguity, but normally we would just say, for example, that X+1 is an
argument to that invocation of the operator “:=” shown in Figure 2.1. (The real argument is the result of
evaluating X+1.)
The update operator “:=” is known as assignment. The command Y := X+1 is an invocation of
assignment, often referred to as just an assignment. The effect of that assignment is to evaluate the
expression X+1, yielding some numerical result r and then to assign r to the variable Y. Subsequent
references to Y therefore yield r (until some command is given to assign something else to Y).
Note the two operands of the assignment: Y is the target, X+1 the source. The terms target and source
here are names for the parameters of the operator. In the example, the argument expression Y is
substituted for the parameter target and the argument expression X+1 is substituted for the parameter
source. We say that target is subject to update, meaning that any argument expression substituted for it
must denote a variable. The other parameter, source, is not subject to update, so any argument expression
substituted must denote a value, not a variable. Y denotes a variable and X+1 denotes a value. When the
assignment is evaluated (or, as we sometimes say of commands, executed), the variable denoted by Y
becomes the argument substituted for target, and the current value of X+1 becomes the argument
substituted for source.
Whereas the Y in Y := X + 1 denotes a variable, as I have explained, the X in Y := X + 1 does not,
as I am about to explain. So now let’s analyse the expression
X+1. It is an invocation of the read-only
operator
+, which has two parameters, perhaps named a and b. Neither a nor b is subject to update. A
read-only operator is one that has no parameter that is subject to update. Evaluation of an invocation of a
read-only operator yields a value and updates nothing. The arguments to the invocation, in this example
denoted by the expressions X and 1, are the values denoted by those two expressions. 1 is a literal,
denoting the numerical value that it always denotes; X is a variable reference, denoting the value currently
assigned to X.
A literal is an expression that denotes a value and does not contain any variable references. But we do not
use that term for all such expressions: for example, the expression 1+2, denoting the number 3, is not a
literal. I defer a precise definition of literal to later in the present chapter.