Previous | Table of Contents | Next |
Numeric literals denote constant non-negative integers or reals. The types of these literals are INTEGER, REAL, LONGREAL, and EXTENDED.
A literal INTEGER has the form base_digits, where base is one of 2, 3, , 16, and digits is a non-empty sequence of the decimal digits 0 through 9 plus the hexadecimal digits A through F. The base_ can be omitted, in which case base defaults to 10. The digits are interpreted in the given base. Each digit must be less than base. For example, 16_FF and 255 are equivalent integer literals.
If no explicit base is present, the value of the literal must be at most LAST(INTEGER). If an explicit base is present, the value of the literal must be less than 2Word.Size, and its interpretation uses the convention of the Word interface. For example, on a 16-bit twos complement machine, 16_FFFF and -1 represent the same value.
A literal REAL has the form decimal E exponent, where decimal is a non-empty sequence of decimal digits followed by a decimal point followed by a non-empty sequence of decimal digits, and exponent is a non-empty sequence of decimal digits optionally beginning with a + or -. The literal denotes decimal times 10exponent. If E exponent is omitted, exponent defaults to 0.
LONGREAL and EXTENDED literals are like REAL, but instead of E, they use D and X, respectively.
Case is not significant in digits, prefixes, or scale factors. Embedded spaces are not allowed.
For example, 1.0 and 0.5 are valid, 1. and .5 are not; 6.624E-27 is a REAL, and 3.1415926535d0 a LONGREAL.
A character literal is a pair of single quotes enclosing either a single ISO-Latin-1 printing character (excluding single quote) or an escape sequence. The type of a character literal is CHAR.
A text literal is a pair of double quotes enclosing a sequence of ISO-Latin-1 printing characters (excluding double quote) and escape sequences. The type of a text literal is TEXT.
Here are the legal escape sequences and the characters they denote:
\n | Newline (linefeed) | |
\f | Form feed | |
\t | Tab | |
\\ | Backslash | |
\r | Carriage return | |
\ | Double quote | |
\ | Single quote | |
\nnn | Char with code 8_nnn |
A \ followed by exactly three octal digits specifies the character whose code is that octal value. A \ that is not a part of one of these escape sequences is a static error.
For example, a and \ are valid character literals, is not; and Dont\n are valid text literals; is not.
The literal NIL denotes the value NIL. Its type is NULL.
A procedure call is an expression if the procedure returns a result. The type of the expression is the result type of the procedure.
A set constructor has the form
S{e1, ..., en}
where S is a set type and the es are expressions or ranges of the form lo..hi. The constructor denotes a value of type S containing the listed values and the values in the listed ranges. The es, los, and his must be assignable to the element type of S.
An array constructor has the form
A{e1, ..., en}
where A is an array type and the es are expressions. The constructor denotes a value of type A containing the listed elements in the listed order. The es must be assignable to the element type of A. This means that if A is a multidimensional array, the es must themselves be array-valued expressions.
If A is a fixed array type and n is at least 1, then en can be followed by
, ..
to indicate that the value of en will be replicated as many times as necessary to fill out the array. It is a static error to provide too many or too few elements for a fixed array type.
A record constructor has the form
R{Bindings}
where R is a record type and Bindings is a list of keyword or positional bindings, exactly as in a procedure call. The list of bindings is rewritten to fit the list of fields and defaults of R, exactly as for a procedure call; the record field names play the role of the procedure formal parameters. The expression denotes a value of type R whose field values are specified by the rewritten binding.
The rewritten binding must bind only field names and must bind each field name exactly once. Each expression in the binding must be assignable to the type of the corresponding record field.
Previous | Table of Contents | Next |