[Issue 9065] Please consider adding these std.traits

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Nov 26 09:59:59 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=9065


Jacob Carlborg <doob at me.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |doob at me.com


--- Comment #16 from Jacob Carlborg <doob at me.com> 2012-11-26 09:59:57 PST ---
(In reply to comment #14)

> Perhaps this will help:
> 
> foreach(m; __traits(allMembers, something))
> {
>   // What on earth is m?
>   // I think think you can argue this is unconventional code.
>   // I need to know all sorts of things about m in this context, and I have
> absolutely no prior information.
>   // 'is' traits shouldn't make me jump through bunches of hoops to gather
> information.
> }

I agree with you in general but what's wrong with that example? Sure, the
double underscore prefix doesn't look that nice but except from that. What
would the alternative be? Something like this:

foreach (m; allMembers!(somethnig))
{
    // What on earth is m?
}

What's better with that code? The "allMembers" trait is clearly documented
here: 

http://dlang.org/traits.html#allMembers

"m" would be a string, since __traits(allMembers, something) returns a tuple of
strings.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list