Thread overview | ||||||
---|---|---|---|---|---|---|
|
January 22, 2009 .tupleof.stringof | ||||
---|---|---|---|---|
| ||||
Check this out! class Foo { int someField; } pragma (msg, Foo.tupleof[0].stringof); // int pragma (msg, Foo.tupleof[0].mangleof); // someField Why is this? It's counterintuitive. |
January 22, 2009 Re: .tupleof.stringof | ||||
---|---|---|---|---|
| ||||
Posted in reply to Christopher Wright | Christopher Wright wrote:
> Check this out!
> class Foo { int someField; }
> pragma (msg, Foo.tupleof[0].stringof); // int
> pragma (msg, Foo.tupleof[0].mangleof); // someField
>
> Why is this? It's counterintuitive.
Oops, no. mangleof does report the mangled name of the input string. It's just that mangleof(i) == i, so my testing incorrectly reported the right result.
Now I need to find a CTFE-able demangle. I think ddl has one.
|
January 22, 2009 Re: .tupleof.stringof | ||||
---|---|---|---|---|
| ||||
Posted in reply to Christopher Wright | Christopher Wright wrote:
> Christopher Wright wrote:
>> Check this out!
>> class Foo { int someField; }
>> pragma (msg, Foo.tupleof[0].stringof); // int
>> pragma (msg, Foo.tupleof[0].mangleof); // someField
>>
>> Why is this? It's counterintuitive.
>
> Oops, no. mangleof does report the mangled name of the input string. It's just that mangleof(i) == i, so my testing incorrectly reported the right result.
No, I'm wrong again. mangleof reports the mangled version of the type.
|
January 22, 2009 Re: .tupleof.stringof | ||||
---|---|---|---|---|
| ||||
Posted in reply to Christopher Wright | Christopher Wright wrote:
> Check this out!
> class Foo { int someField; }
> pragma (msg, Foo.tupleof[0].stringof); // int
> pragma (msg, Foo.tupleof[0].mangleof); // someField
>
> Why is this? It's counterintuitive.
Okay, no, this example is a shorter version of something else that exemplified this behavior:
foreach (i, field; Foo.init.tupleof)
pragma (msg, field.stringof);
This has the results I described. However, the following has the expected result:
pragma (msg, Foo.init.tupleof[0].stringof);
|
Copyright © 1999-2021 by the D Language Foundation