Qualified Names / Re: Standardized Predefined CPP Symbols ...

Clay Phipps phipps at fortune.UUCP
Thu Jul 19 07:14:43 AEST 1984


In regard to the suggestion that

    these predefined symbols ... ought to be chosen so that they are 
    not likely to be accidentally used as variables in somebody's program.
    ...
    If predefined symbols were all to begin and end with underscore characters,
    and this fact were documented,
    then nobody would fall into the trap of inadvertently using one.

Why do I continually run across the suggestion that prefixing names
with underscores makes them unique, as if no one has used underscore
characters for some special purpose before ?  
Sorry, the underscore has already been spoken for.
The VAX C compiler uses that convention for external names, for example.
Conventional VAX UN*X subroutines names, therefore, all begin with "_".
Making names all upper case isn't adequate, either, at least for Berkeley
Pascal under UN*X [no flames, please; some customers *do* want Pascal,
and some want it *badly*; if this weren't the case,
I might be able to get the shackle off my ankle and take some vacation],
because the Berkeley Pascal runtimes' names are all upper case.
Define a variable whose name happens to be the same as one of those routines,
for example, "IN" (Pascal "in" operator), and watch the sparks fly !

What is really needed is a name qualification or prefixing convention
that can be applied across all of UN*X, for example,

    <prefix> "_" <mnemonic name>

The prefix would be the name of the program or routine package;
for example, "cpp" for the C Preprocessor, "lp" for the Pascal Library, &c.
Thus, "unix" would become, for example, "cpp_unix", 
"waterloo" would be "cpp_waterloo", and Pascal Library "IN" could be "lp_in".
This isn't perfect, but it's much better than what we have now.
Too bad that use of the UN*X subroutines with unqualified names,
for example, "read", "write" is too well established to change now.

-- Clay Phipps

-- 
            { amd  hplabs!hpda  sri-unix  ucbvax!amd }          
                                                      !fortune!phipps
   { ihnp4  cbosgd  decvax!decwrl!amd  harpo  allegra}



More information about the Comp.unix mailing list