On 2011-03-10 09:44, Nick Sabalausky wrote:
"Tomek Sowiñski"<[email protected]> wrote in message
news:20110309225011.3e9e1d3b@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. :)
Not sure but if I recall correctly you can do ".stringof" to get the
name of the module.
--
/Jacob Carlborg