[net.lang.c] Hashing to generate unique 6-char names

kpmartin@watmath.UUCP (Kevin Martin) (10/19/84)

Unfortunately, I lost the original article. It was about 80 to 100 lines
extolling the virtues of hashing to generate a six-character identifier
from a longer one.

The article claims that the only way one can get undetected clashes is
through an incorrect program (two clashing references, but only one of the
variables actually defined). Unfortunately, correct programs can also
get undetected errors. Assume the names 'x' and 'y' happen to hash the same.
In file extern.c:
	int x = 5;
	int y = 10;

Since the two variables clash, 'y' gets re-hashed. Now, in foo.c:
	foo() {
		x = 10;
	}

and in bar.c:
	bar() {
		y = 10;
	}

Surprise! Both foo and bar assign 10 to 'x', leaving 'y' untouched.


Although hashing appears to make all the characters significant, it
actually makes all the characters partially significant in a manner that
is impossible to describe to the user. At least truncating the name to six
characters (or whatever) is an easy concept to explain.
                   Kevin Martin, UofW Software Development Group