section 2.1: Variable Names

Deep sentence:

Don't begin variable names with underscore, however, since library routines often use such names.
If you happen to pick a name which ``collides'' with (is the same as) a name already chosen by a library routine, either your code or the library routine (or both) won't work. Naming issues become very significant in large projects, and problems can be avoided by setting guidelines for who may use which names. One of these guidelines is simply that user code should not use names beginning with an underscore, because these names are (for the most part) ``reserved to the implementation'' (that is, reserved for use by the compiler and the standard library).

Note that case is significant; assuming that case is ignored (as it is with some other programming languages and operating systems) can lead to real frustration.

The convention that all-upper-case names are used for symbolic constants (i.e. as created with the #define directive, which we learned about in section 1.4) is arbitrary, but useful. Like the various conventions for code layout (page 10), this convention is a good one to accept (i.e. not get too creative about), until you have some very good reason for altering it.

Deep sentence:

Keywords like if, else, int, float, etc., are reserved; you can't use them as variable names.
You can find the complete list of keywords in appendix A2.4 on page 192.


Read sequentially: prev next up top

This page by Steve Summit // Copyright 1995, 1996 // mail feedback