Go to the first, previous, next, last section, table of contents.


5.2.3 Type Specifiers

The syntax of type specifiers is as in C++ (see Section r.7.1.6 of [Stroustrup91]).

type-specifier-seq ::= type-specifier [ type-specifier ] ...
type-specifier ::= simple-type-name
        | enum-specifier | class-specifier
        | elaborated-type-specifier | cv-qualifier
cv-qualifier ::=  const | volatile

Usually only one type-specifier may be given in a declaration. But const or volatile may be added to the others (see Section r.7.1.6 of [Stroustrup91]), and some combinations of built-in type names may be used to make types such as unsigned int. In the following, each line is a legal type-specifier-seq.

double                       // simple type names
MyClass
unsigned int
long double
const int                    // cv-qualifier + simple type name
const unsigned int
struct myStruct { int x,y; } // class-specifier
enum color {red,white,blue}  // enum-specifier
struct MyStruct              // elaborated-type-specifiers
enum color
typename MyStruct

The Larch/C++ meaning of const is discussed below (see section 5.4.7 Constant Declarations).

The type specifier volatile says that the value of an object may be changed by concurrent processes, etc.

The type-specifier may be omitted from a declaration, and defaults to int. However, omitting the type specification is bad style in a Larch/C++ specification. This default is also slated to be removed from C++, and hence from Larch/C++. In short, do not use this default.

See section 7 Class Specifications for details on the class-specifier. See section 5.3 Enumeration Declarations for details on the enum-specifier.


Go to the first, previous, next, last section, table of contents.