|name mangling advice requested email@example.com (John R Levine) (1998-09-05)|
|Re: name mangling advice requested firstname.lastname@example.org (Ray Dillinger) (1998-09-13)|
|Re: name mangling advice requested email@example.com (Tom Moog) (1998-09-13)|
|Re: name mangling advice requested firstname.lastname@example.org (1998-09-13)|
|Re: name mangling advice requested email@example.com (1998-09-18)|
|Re: name mangling advice requested firstname.lastname@example.org (Ehud Lamm) (1998-09-22)|
|From:||Ray Dillinger <email@example.com>|
|Date:||13 Sep 1998 22:25:07 -0400|
John R Levine wrote:
> I'm working on the symbol management part of the linker book, and I want
> to sound intelligent when I discuss name mangling. I know what g++ does,
> and I know what a lot of PC C (pre-C++, it was a while ago), do, but I'd
> appreciate reports of how names are mangled on other C++ compilers, as
> well as other languages that do something similar.
> For example, back in ancient days, did COBOL programmers who were used to
> variable names like weekly-pay-before-deducting-baksheesh really put up
> with six or eight character linker limits?
*sigh* Yes, we did. (Gods I feel old...)
The limits you're referring to didn't originate as linker limits. The
compilers that were built to go with those linkers had the same
limitation; you could use a variable name as long as you wanted, but
unless a difference appeared within the first few characters the
compiler, let alone the linker, didn't notice it. So it was a
*system* limitation, and everybody knew that every variable everywhere
had to be unique within the first few characters.
The compilers got better a long time before the linkers; there was a
lot of resistance to changing the linkable formats because of backward
compatibility issues, but through some hacks it became possible to
have the distinctions between long variable names recognized *within*
a module provided that variable was one that didn't have to be linked.
I used a compiler for the Vax once that accepted variable names up to
256 characters long, but didn't actually notice the difference between
them unless it happened within the first six characters.
The programmers of course took this as a reason to restrict variable
names to six characters, but management, Gods bless 'em, at that point
in history were still curious enough about programming to actually
want to read the code and know what was going on, so an order came
down that said, basically, use verbose variable names so the suits can
understand what your code does.
So the programmers wound up creating unique prefixes to lead the
mnemonic variable names so the compiler wouldn't confuse all the
different variables starting, for example, with "weekly-".
The unique prefix of choice, at least at our shop, because you could
remember the method rather than a different arbitrary prefix for each
variable, was the initials of its verbose name. So instead of writing
"weekly-pay-before-deducting-baksheesh" we'd wind up writing something
like "WPBDB-weekly-pay-before-deducting-baksheesh". If there were too
many variables with the same first few initials we would substitute
numbers for the last few of the initials.
More recently I've been amused to see "echos" of this process with the
rise in popularity of so-called hungarian notation and the creation of
8.3 DOS filenames for Windows files with long names.
Return to the
Search the comp.compilers archives again.