[gnu.g++] Shorter names

tiemann@ARKESDEN.ENG.SUN.COM (Michael Tiemann) (09/21/89)

In an effort to generate shorter mangled names, here is something
compilers can do, but only if all compilers that must interoperate
adopt the convention.  There seem to be a number of names which are
almost always found being used in C++ programs: Integer, String,
Object, etc.  We could build a dictionary of all classnames that are
found in existing implementations, sorted by apparent frequency of
usage, and then these names could be refered to by their index in the
dictionary.  Suppose that `ostream' is index 2 and `Integer' is index
number 10.  Then the function

	ostream& Integer::PrintOn(ostream&)

would be mangled as

	PrintOn__D10D2

instead of

	PrintOn__7Integer7ostream

This has the problem of adding significant state to an implementation
definition of a C++ compiler, so one might want to limit it to say the
100 most common class names.  It would not be hard to implement: using
Doug Schmidt's `gperf' program, a perfect hashing function could be
used to generate code that all C++ compiler implementors could use for
efficient lookup and consistent name-index associations, and the code
for the function could be published as a standard.

I am not proposing that this be done immediately, but it might be
something to think about.

Michael