DMD 1.005 release

Bruno Medeiros brunodomedeiros+spam at com.gmail
Thu Feb 15 02:54:39 PST 2007


Walter Bright wrote:
> 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.

Erm, shouldn't T.stringof be "T" and not "Abc" nor even "Foo.Bar.Abc"?

-- 
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d-announce mailing list