Here is the required syntax for an identifier in BNF format:
identifier ::= letter { [ "_" ] letter_or_digit }
letter_or_digit ::= letter | digit
All characters of an identifier are significant, and Ada compilers must support lines and identifier lengths of at least 200 (!) characters. Hopefully you won't use that many, of course, but the idea is to be very flexible.
One implication of this syntax is that underscores must not be adjacent to each other. This was intentional, because on some printers two adjacent underscores look the same as one underscore. Underscores also can't begin or end an identifier.
You can use single letters as identifiers, but don't abuse this ability. If your program uses only single-letter identifiers it will be very difficult to decipher later. It's best to use identifiers that clearly state what they store or what they do. Also, while the Ada language permits the single letters "L" and "O" to be identifiers, I recommend against it - a lower case letter "L" is nearly indistinguishable from the digit one (1), and an upper case letter "O" is nearly indistinguishable from the digit zero (0) on some systems.
Here are some lists of identifiers:
Which of the preceding lists have only legal identifiers (ignoring the commas, which are there to separate the identifiers)?
![]() |
![]() |
![]() |
---|
David A. Wheeler (dwheeler@ida.org)