Thread overview | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
June 09, 2006 demangle and mangleof | ||||
---|---|---|---|---|
| ||||
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 |
June 09, 2006 Re: demangle and mangleof | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bradley Smith | 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 |
June 09, 2006 Re: demangle and mangleof | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don Clugston | 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
|
July 07, 2006 Re: demangle and mangleof | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Reimer | 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!
|
July 07, 2006 Re: demangle and mangleof | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don Clugston | 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 +/ |
July 07, 2006 Re: demangle and mangleof | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tom S | 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.
|
July 07, 2006 Re: demangle and mangleof | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don Clugston | 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 +/ |
July 08, 2006 Re: demangle and mangleof | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tom S | 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.
|
July 09, 2006 Re: demangle and mangleof | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don Clugston | 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!
|
July 09, 2006 Re: demangle and mangleof | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don Clugston | 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 +/ |
Copyright © 1999-2021 by the D Language Foundation