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

           Summary: support "is (T : struct)" syntax
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: [email protected]
        ReportedBy: [email protected]


--- Comment #0 from [email protected] 2013-09-25 07:19:57 PDT ---
As well as:
is (T : class)
is (T : interface)
is (T : union)

This could be useful in two scenarios:

The case where T represents a enum instance of said type. For example:
struct T {}
enum E : T {a = T.init}

In this case, E being an enum, it isn't a struct, however, it would be useful
to know if it can "decay" to a struct type. This syntax would make proper enum
handling correct "by default" rather than explicitly, EG:
is (T : struct)
vs
is (OriginalType!T == struct)

This (I think), is actually quite important, as it increases the chances of
code being correct with no special extra content, as well as lower the overall
complexity.



Another case where this could be useful, is if T defines an alias this that
resolves to another type:

class C
{
    T t;
    alias t this;
}

is (T == struct); //false
is (T : struct); //true

Related conversation:
http://forum.dlang.org/thread/[email protected]

Also, as a general rule, it's more consistent. If:
is (T : U);

is legal, then so should:
is (T : struct);

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

Reply via email to