demangle and mangleof

Don Clugston dac at nospam.com.au
Fri Jun 9 03:29:57 PDT 2006


Bradley Smith wrote:
> 
> Does it seem reasonable that the demangle() function should work for the 
> .mangleof property?

It seems very reasonable to me. I have implemented compile-time demangle 
metafunctions:

static assert( prettynameof!(A)    == "class main.A" );
static assert( qualifiednameof!(A) == "main.A" );
static assert( symbolnameof!(A)    == "A" );

When doing this, I found some mistakes in the name mangling docs, and 
I'm pretty sure that my code is much more comprehensive than std.demangle.

A really old version of the code is in dsource.ddl.meta, but it was 
ugly, and improvements to the template system have broken it. I'll post 
my new version soon (was working on it today, still fails in a few cases).

> 
> 
> private import std.stdio;
> private import std.demangle;
> 
> void main() {
>     class A {
>     }
>     writefln(A.mangleof);
>     writefln(demangle(A.mangleof));
> }
> 
> This code prints
> 
> C_Dmain1A
> C_Dmain1A
> 
> It would be nice if it printed
> 
> C_Dmain1A
> class main.A

> 
> 
> Does the D language even have the concept of a fully qualified class 
> name? The property .classinfo.name is just the simple name of a class.
> 
> The AssertError also just prints the simple file name rather than the 
> source file path. This makes the error less useful when having modules 
> with the same name in different packages.
> 
> Thanks,
>   Bradley



More information about the Digitalmars-d-learn mailing list