Pop quiz, what does this do?
Steven Schveighoffer
schveiguy at gmail.com
Wed Mar 3 16:52:01 UTC 2021
On 3/3/21 11:41 AM, Simen Kjærås wrote:
> On Wednesday, 3 March 2021 at 16:06:48 UTC, Steven Schveighoffer wrote:
>> The FieldNameTuple from std.traits returns a tuple of names of all the
>> fields that are present on a type instance.
>>
>> What about the result on things that can't have fields?
>>
>> import std.traits;
>>
>> interface I
>> {
>> int foo();
>> }
>>
>> pragma(msg, FieldNameTuple!I);
>>
>> Without looking up the docs, or trying it, what do you think it does?
>
> I remember seeing that a couple years back
> (https://forum.dlang.org/post/hwrsxypruzeffreqxasa@forum.dlang.org). It
> seems intentional, but also very, very weird.
Oh snap! almost 2 years ago, I had the same exact WTF moment.
Except this time, it is affecting code that I have to fix.
> Accordion to the PR (https://github.com/dlang/phobos/pull/2561), it was
> for consistency. Consistency with what, however, is unclear.
Thanks for the link. I think it's consistently uninutitive...
-Steve
More information about the Digitalmars-d
mailing list