[m-dev.] name mangling

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Nov 19 18:19:28 AEDT 2001


On 19-Nov-2001, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> I propose to change the name mangling scheme so that names containing chars
> that are not acceptable in C identifiers (e.g. '[' and ']') are mangled
> by modifying only the non-C-id parts. The scheme I propose is:
> 
> - Replace every character that is not acceptable in a C identifier with
>   'z_N_', where N is a sequence of digits giving the characters' ASCII code.
> 
> - Replace every occurrence of 'z_' in the original name with 'z__'.

The current name mangling scheme has special cases for
commonly used symbols such as '*', '+', etc., which get
mapped to 'f_plus', 'f_times', etc. rather than to 'f_42', 'f_43', etc.
This makes it easier to read the mangled source.

I think it would be a good idea to do the same with the new scheme,
although the special cases would be for characters rather than
for whole symbols.  So for example `=<' would get mangled to
something like 'z_equal_z_lessthan_'.  Or perhaps 'z_EQ_z_LT',
if you want something more concise.

The characters that I think are worth special-casing are all those that
appear on a standard keyboard.

Otherwise that sounds fine with me.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list