FieldNameTuple!T and std.traits.Fields!T not empty for interfaces

Amex Amex at gmail.com
Fri Jun 7 09:27:29 UTC 2019


On Thursday, 6 June 2019 at 20:52:42 UTC, Steven Schveighoffer 
wrote:
> On 6/6/19 4:49 PM, Steven Schveighoffer wrote:
>> Oh wait! It's not empty, it has an empty string as a single 
>> member! That's definitely a bug.
>> 
>
> OK, not a bug, but not what I would have expected. From docs:
>
> "If T isn't a struct, class, or union, an expression tuple with 
> an empty string is returned."
>
> I wonder why that behavior is there, certainly it's intentional.
>
> -Steve

It is wrong, regardless if it is intentional. Every day people do 
intentional things that are wrong.

The problem is that one returns a non-empty tuple and so loops 
will be executed on the empty string. While one can test for the 
empty string return there is absolutely no reason why one 
shouldn't just return an empty tuple as it plays correctly with 
the use case.




More information about the Digitalmars-d-learn mailing list