DMD 1.005 release

Walter Bright newshound at digitalmars.com
Tue Feb 13 11:25:00 PST 2007


Don Clugston wrote:
> Walter Bright wrote:
>> Bruno Medeiros wrote:
>>> Well, actually you can do that, with the unannounced (in the 
>>> changelog) .stringof property ( 
>>> http://www.digitalmars.com/d/property.html ) :
>>>
>>> ----
>>>
>>> template MakeVariable(Type, char[] name)
>>> {
>>>   const char[] MakeVariable = Type.stringof ~ " " ~ name ~ ";";
>>> }
>>
>> It's unannounced because it doesn't work right yet.
> 
> <trashes meta.nameof>
> It was a piece of code I was particularly proud of. Ah well.
> </trashes>
> 
> It seems that 90% of the metaprogramming code I've ever written has been 
> made obsolete by being incorporated into the code language.
> My 'workarounds' file went from 16 entries to zero.
> 
> But the ability to do it for an expression as well is quite exciting; it 
> seems that this could easily supercede lazy parameters.
> So I'm not complaining <g>.

The big problem with .stringof is the following:

	alias Foo.Bar.Abc T;
	typedef int Abc;
	const char[] s = T.stringof;
	typeof(mixin(s)) x;

s is given the string "Abc". So, when the mixin evaluates s, it resolves 
to the local declaration of Abc, not the fully qualified one.



More information about the Digitalmars-d-announce mailing list