DMD 1.005 release

Don Clugston dac at nospam.com.au
Wed Feb 14 06:44:47 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.

Isn't it always going to be true that the scope where stringof is 
applied, could be different from where it is mixed in?

That's why I figured that the concept of symbolnameof (the minimal 
descriptor in the scope) was different from qualifiednameof (valid in 
any scope). Of course, you've got access to much more information than I 
did, so perhaps there's a cleaner solution.



More information about the Digitalmars-d-announce mailing list