full ident name without mangle/demange?

Nick Sabalausky a at a.a
Thu Mar 10 00:44:13 PST 2011


"Tomek Sowiñski" <just at ask.me> wrote in message 
news:20110309225011.3e9e1d3b at Las-Miodowy...
>Nick Sabalausky napisa³:
>
>> Is there a way to get the fully-qualified name of an identifier without
>> doing "demange( mangledName!(foo) )"?
>
>Heh, looks like there isn't. It may be worth filing an enhancement request 
>for __traits(fullyQualifiedName, foo).
>


Yea, I guess so.


>BTW, what do you need it for?
>


Well, it's kind of round-about: It's to obtain the module name of an 
identifier. This, in turn, is for a trick to automatically detect and print 
the name of the current module in a unittest tool:

http://www.dsource.org/projects/semitwist/browser/trunk/src/semitwist/util/unittests.d?rev=202#L177

It had been working using mangledName and demangle, but it broke when I 
updated to DMD 2.052:

http://d.puremagic.com/issues/show_bug.cgi?id=5718

I did eventually manage to work around the issue, though, at least in my 
particular case.

But I figure if I'm going to get either the fully-qualified name or a module 
name, why have the CPU even go through the bother of sending it through the 
potentially error-prone and/or non-CTFE-compatible noop of mangle->demange?

That in mind, something like __traits(moduleName, foo) and 
__traits(thisModuleName) would probably be good enhancement suggestions, 
too.  :)





More information about the Digitalmars-d-learn mailing list