www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - full ident name without mangle/demange?

reply "Nick Sabalausky" <a a.a> writes:
Is there a way to get the fully-qualified name of an identifier without 
doing "demange( mangledName!(foo) )"?
Mar 07 2011
parent reply Tomek =?ISO-8859-2?B?U293afFza2k=?= <just ask.me> writes:
Nick Sabalausky napisa=B3:

 Is there a way to get the fully-qualified name of an identifier without=20
 doing "demange( mangledName!(foo) )"?
Heh, looks like there isn't. It may be worth filing an enhancement request = for __traits(fullyQualifiedName, foo). BTW, what do you need it for? --=20 Tomek
Mar 09 2011
parent reply "Nick Sabalausky" <a a.a> writes:
"Tomek Sowiński" <just ask.me> 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. :)
Mar 10 2011
parent Jacob Carlborg <doob me.com> writes:
On 2011-03-10 09:44, Nick Sabalausky wrote:
 "Tomek Sowiński"<just ask.me>  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
Mar 10 2011