www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Fully qualified name of an identifier as a compile-time string

reply =?ISO-8859-1?Q?Adam_Cig=E1nek?= <adam.ciganek gmail.com> writes:
Hello,

Is there a way to get a fully qualified name of an identifier as a
string during compile time? __traits(identifier) returns only
unqualified name.

adam.
Oct 27 2010
next sibling parent "Nick Sabalausky" <a a.a> writes:
"Adam Cigánek" <adam.ciganek gmail.com> wrote in message 
news:mailman.12.1288206056.21107.digitalmars-d-learn puremagic.com...
 Hello,

 Is there a way to get a fully qualified name of an identifier as a
 string during compile time? __traits(identifier) returns only
 unqualified name.

You could try 'identifier.stringof'. But I don't know if that'll give you what you want, and .stringof does have a history of being buggy, poorly-defined, and frequently changing.
Oct 28 2010
prev sibling next sibling parent =?ISO-8859-2?Q?Adam_Cig=E1nek?= <adam.ciganek gmail.com> writes:
 You could try 'identifier.stringof'. But I don't know if that'll give you
 what you want, and .stringof does have a history of being buggy,
 poorly-defined, and frequently changing.

Thanks, but stringof gives unqualified name as well. Are foo.stringof and __traits(identifier, foo) the same thing?
Oct 28 2010
prev sibling parent Philippe Sigaud <philippe.sigaud gmail.com> writes:
Hello,

you could try core.demangle.demangle(identifier.mangleof)

the .mangleof gives access to the qualified name and demangle preserves it.
IIRC there are now two demanglers in Phobos, one in std.demangle, that
will be deprecated and another one in core.*
Sorry not to be more precise, I don't have access to Phobos/DMD right now.


Philippe
Oct 28 2010