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


4.6 Identifiers

As in C++, identifiers are used to name functions, variables, etc.

identifier ::= letter [ letter-or-digit ] ...
            | ident( letter [ letter-or-digit ] ... )
letter ::= _, a through z, or A through Z
digit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
letter-or-digit ::= letter | digit

The usual form of an identifier is an arbitrary long sequence of letters and digits. The first character of an identifier must be a letter; the underscore (_) is treated as a letter. (The alphabetic letters only include ASCII codes, no codes for accented characters are included.) Identifiers are case sensitive; i.e., identifier, Identifier, and IDENTIFIER are three distinct identifiers.

Some names that would otherwise be identifiers are reserved by Larch/C++ (see section 4.8 Keywords for a list of Larch/C++ keywords). In a few rare cases, one needs to use a Larch/C++ keyword as the name of something to be specified. This is the reason for the other form of identifier. For example, ident(reach) means the identifier reach, not the Larch/C++ keyword reach. (Note that no whitespace is allowed between the parts of such an identifier.) This syntax allows one to use the C++ macro defined in the following, so that C++ will not gag on this form of identifier.

// @(#)$Id: ident_macro.lh,v 1.2 1997/05/25 00:19:37 leavens Exp $
#ifndef __ident_macro_lh__
#ifndef ident_macro_lh
#define ident_macro_lh

#define ident(x) x

#endif
#endif

Identifiers may live in several different worlds in Larch/C++. There are 3 different such worlds: trait names, names of specified C++ entities, and all other names. The last world includes trait function names (including prefix, infix, and postfix trait functions) and sort names that are not type names. The same identifier may thus be used in these worlds with different meanings. For example, in Larch/C++, int is both the name of a trait and the name of a C++ type.


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