Lady Ada

Ada '83 Language Reference Manual

Copyright 1980, 1982, 1983 owned by the United States Government. Direct reproduction and usage requests to the Ada Information Clearinghouse.

4.2. Literals


A literal is either a numeric literal, an enumeration literal, the literal null, or a string literal. The evaluation of a literal yields the corresponding value.

Numeric literals are the literals of the types universal_integer and universal_real. Enumeration literals include character literals and yield values of the corresponding enumeration types. The literal null yields a null access value which designates no objects at all.

A string literal is a basic operation that combines a sequence of characters into a value of a one-dimensional array of a character type; the bounds of this array are determined according to the rules for positional array aggregates (see 4.3.2). For a null string literal, the upper bound is the predecessor, as given by the PRED attribute, of the lower bound. The evaluation of a null string literal raises the exception CONSTRAINT_ERROR if the lower bound does not have a predecessor (see 3.5.5).

The type of a string literal and likewise the type of the literal null must be determinable solely from the context in which this literal appears, excluding the literal itself, but using the fact that the literal null is a value of an access type, and similarly that a string literal is a value of a one-dimensional array type whose component type is a character type.

The character literals corresponding to the graphic characters contained within a string literal must be visible at the place of the string literal (although these characters themselves are not used to determine the type of the string literal).


    3.14159_26536  --  a real literal
    1_345          --  an integer literal
    CLUBS          --  an enumeration literal
    'A'            --  a character literal
    "SOME TEXT"    --  a string literal 

References: access type, aggregate, array, array bound, array type, character literal, character type, component type, constraint_error exception, designate, dimension, enumeration literal, graphic character, integer literal, null access value, null literal, numeric literal, object, real literal, string literal, type, universal_integer type, universal_real type, visibility.

Rationale references: 2.1 Lexical Structure

Style Guide references: 8.2.4 Subtypes in Generic Specifications


[Ada Information Clearinghouse]

Address any questions or comments to