1.4 Sentences and Programs

A Refal program is a list of function definitions. It may also contain external references (which will be discussed in Chapter 2) and comment lines. A comment line starts with an asterisk * , and has no effect on the execution of the program. Comment lines may appear both between and inside function definitions. The order in which function definitions enter the program has no significance.

A function definition has one of these forms:

function-name { block }

$ENTRY function-name { block } The significance of the prefix $ENTRY will be discussed in Chapter 2 together with the use of external references.

A function name is an identifier. A block is a list of sentences separated by semicolons; the last sentence may be followed by a semicolon, also. The order of sentences in a function definition is significant.

A sentence has the form:

left-side = right-side

where the left side is a pattern expression and the right side is a general expression. Recall that an object expression may include only symbols and structure brackets and that a pattern expression may, in addition, include free variables. A general expression, in addition to the constituents of pattern expressions, may include evaluation brackets < and >. They enter as parts of function calls:

<function-name  argument>

where function-name is either an identifier or one of the four arithmetic operation signs (+ , - , * , and / ); and argument is a general Refal expression. Thus, evaluation brackets can be nested. Note that the function name must follow immediately after the opening evaluation bracket, without intervention of blanks or line transfers.

The following restriction on the right side is important: the right side can include only such free variables which also enter the left side (see next section). There is also a technical restriction: variable indexes must be unique, i.e., you can use eX and s1 any number of times but if you use eX you cannot use sX or tX in the same sentence; using s1 excludes e- and t-variables with index 1 .

In addition to comment lines, sentences may include comments which start with /* and end with */ . They can appear anywhere provided that they do not break up lexical elements (identifiers, numbers, strings, variables) and do not tear a left evaluation bracket from the following function name.