Some points to express its appropriateness:
Concise and Precise
The term nondigit is a concise and precise way to refer to a specific set of characters that are not digits and can be used in naming identifiers. It is clear and unambiguous, and avoids any confusion that may arise from using a more general term like letter-or-underscore.
Widely Used (can be considered)
The term nondigit is widely used in the programming community, not just in C, but also in other programming languages like Java and C++. This makes it a familiar and recognizable term for programmers who are familiar with multiple languages.
Specific to Identifiers
The term nondigit is specifically used in the context of naming identifiers, which are an important aspect of the C language. Using a more general term like letter-or-underscore could potentially include characters that are not valid for use in identifiers, such as special characters or foreign letters with diacritical marks.
Historical Context
The term nondigit has been used in the C language since its earliest versions, and is likely a holdover from the language's predecessor, B. This historical context adds to the appropriateness of the term in the C language.
The use of the term in the B programming language, which influenced the development of C, suggests that it was chosen for historical reasons.
The B language had a similar syntax to C and used nondigit to refer to the set of characters that could be used in identifiers, as seen in this snippet of B code:
main( ) {
auto a, b, c, sum;
a = 1; b = 2; c = 3;
sum = a+b+c;
putnumb(sum);
}
(For additional information auto is used to define 36-bit variables in B)
It is likely that the term nondigit was carried over from B into C, as C was developed as an extension of B. The use of nondigit has persisted in subsequent versions of the C standard, including the current C18 standard.
Furthermore, the use of concise and unambiguous language is a common practice in programming language specifications. This can be seen in the use of terms like whitespace and newline to describe specific sets of characters, rather than more descriptive terms like blank space or line break. The use of nondigit in C follows this practice, providing a clear and specific definition of the set of characters that can be used in identifiers.
While it may seem more descriptive to use a term like letter-or-underscore to describe this set of characters, it is important to note that this could potentially lead to confusion or misinterpretation. For example, it is possible for a programming language to include other special characters in its set of valid identifier characters, such as accented letters or currency symbols. Using a more specific term like nondigit makes it clear that only the characters listed in the C specification are valid for use in identifiers.
Ultimately, the use of the term nondigit in C is a matter of convention and historical precedent. While it may not be the most descriptive term, it has been used in the language for many years and is well-established in the C specification.
Thankful to @PeteKirkham for pointing out mistakes and for additional resources.
Sources of information
- The Development of the C Language
- A Tutorial Introduction
To The Language B