www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - demangle and mangleof

reply Bradley Smith <digitalmars-com baysmith.com> writes:
Does it seem reasonable that the demangle() function should work for the 
.mangleof property?


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
Jun 09 2006
parent reply Don Clugston <dac nospam.com.au> writes:
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
Jun 09 2006
parent reply John Reimer <terminal.node gmail.com> writes:
Don Clugston wrote:
 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).
I eagerly await your improvements. :) -JJR
Jun 09 2006
parent reply Don Clugston <dac nospam.com.au> writes:
John Reimer wrote:
 Don Clugston wrote:
 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).
I eagerly await your improvements. :) -JJR
It's done. I've also added prettytypeof!(T) which converts any type into a string. auto x = 5.0; static assert( prettytypeof!( x ) == "double"); These functions works with just about anything I've thrown at them. Try to break it! Enjoy!
Jul 07 2006
parent reply Tom S <h3r3tic remove.mat.uni.torun.pl> writes:
Don Clugston wrote:
 It's done.
 I've also added prettytypeof!(T) which converts any type into a string.
 
 auto x = 5.0;
 static assert( prettytypeof!( x ) == "double");
Cool :)
 These functions works with just about anything I've thrown at them. Try 
 to break it!
 Enjoy!
Sure thing ! http://158.75.59.9/~h3/code/nameofBreak.rar -- Tomasz Stachowiak /+ a.k.a. h3r3tic +/
Jul 07 2006
parent reply Don Clugston <dac nospam.com.au> writes:
Tom S wrote:
 Don Clugston wrote:
 It's done.
 I've also added prettytypeof!(T) which converts any type into a string.

 auto x = 5.0;
 static assert( prettytypeof!( x ) == "double");
Cool :)
 These functions works with just about anything I've thrown at them. 
 Try to break it!
 Enjoy!
Sure thing ! http://158.75.59.9/~h3/code/nameofBreak.rar
That was quick! Hopefully I'll post a fix tonight. I notice you're using the 'meta' namespace for your Tuple code. How about joining forces and making a compelling D metaprogramming library? Previously, my 'meta' library was just proof-of-concept stuff, but it's time to turn it into something serious. Oskar's done a lot of fantastic stuff too, although his seems to be more relevant at run time.
Jul 07 2006
next sibling parent reply Tom S <h3r3tic remove.mat.uni.torun.pl> writes:
Don Clugston wrote:
 I notice you're using the 'meta' namespace for your Tuple code. How 
 about joining forces and making a compelling D metaprogramming library?
 Previously, my 'meta' library was just proof-of-concept stuff, but it's 
 time to turn it into something serious.
 Oskar's done a lot of fantastic stuff too, although his seems to be more 
 relevant at run time.
I'd be more than eager to cocreate such a library. There's a D lib in the works that could use a 'meta' component... :> -- Tomasz Stachowiak /+ a.k.a. h3r3tic +/
Jul 07 2006
parent Don Clugston <dac nospam.com.au> writes:
Tom S wrote:
 Don Clugston wrote:
 I notice you're using the 'meta' namespace for your Tuple code. How 
 about joining forces and making a compelling D metaprogramming library?
 Previously, my 'meta' library was just proof-of-concept stuff, but 
 it's time to turn it into something serious.
 Oskar's done a lot of fantastic stuff too, although his seems to be 
 more relevant at run time.
I'd be more than eager to cocreate such a library. There's a D lib in the works that could use a 'meta' component... :>
I'm in. If you make arrangements to set up the meta directory, I'll start contributing. Let's get this ship afloat.
Jul 08 2006
prev sibling parent reply Don Clugston <dac nospam.com.au> writes:
Don Clugston wrote:
 Tom S wrote:
 Don Clugston wrote:
 It's done.
 I've also added prettytypeof!(T) which converts any type into a string.

 auto x = 5.0;
 static assert( prettytypeof!( x ) == "double");
Cool :)
 These functions works with just about anything I've thrown at them. 
 Try to break it!
 Enjoy!
Sure thing ! http://158.75.59.9/~h3/code/nameofBreak.rar
That was quick! Hopefully I'll post a fix tonight.
I've fixed it. Try to break it again!
Jul 09 2006
parent reply Tom S <h3r3tic remove.mat.uni.torun.pl> writes:
Don Clugston wrote:
 I've fixed it. Try to break it again!
http://158.75.59.9/~h3/code/kknd.rar "Shall we play a game ?" :D -- Tomasz Stachowiak /+ a.k.a. h3r3tic +/
Jul 09 2006
parent reply Don Clugston <dac nospam.com.au> writes:
Tom S wrote:
 Don Clugston wrote:
 I've fixed it. Try to break it again!
http://158.75.59.9/~h3/code/kknd.rar
Somehow, you aren't using the fixed version. That example worked for me with latest meta.demangle.
 "Shall we play a game ?" :D
Why not, I'm enjoying this. Every time you kill me, I come back stronger...
Jul 09 2006
parent Tom S <h3r3tic remove.mat.uni.torun.pl> writes:
Don Clugston wrote:
 Tom S wrote:
 Don Clugston wrote:
 I've fixed it. Try to break it again!
http://158.75.59.9/~h3/code/kknd.rar
Somehow, you aren't using the fixed version. That example worked for me with latest meta.demangle.
Hmmm weird. I grabbed it from SVN using the ... hmm... browser interface. Might've been cache. Sorry for that.
 "Shall we play a game ?" :D
Why not, I'm enjoying this. Every time you kill me, I come back stronger...
Hrm. I'll have to 'kill -9' you next time. I'll try to break it again a bit later :) -- Tomasz Stachowiak /+ a.k.a. h3r3tic +/
Jul 10 2006