[Issue 8762] New: instanceOf trait for static conditionals

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Oct 5 02:35:06 PDT 2012


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

           Summary: instanceOf trait for static conditionals
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: monarchdodra at gmail.com


--- Comment #0 from monarchdodra at gmail.com 2012-10-05 02:23:10 PDT ---
As discussed here:
http://forum.dlang.org/thread/ssqgyxzggmzugbfbboay@forum.dlang.org

The idea would be a trait "instanceOf!T" that returns a reference to a T. The
advantage of this approach is that it allows "extracting" an instance out of T,
without ever worrying about how or where said instance came from.

This is particularly important because some types don't have T.init, and
immutables don't have T t = void. The intersection of both these groups is {0}
...

Example:
//----
template isAssignable(T, U)
{
    enum bool isAssignable =
        is(typeof(instanceOf!T = instanceOf!U));
}
//----

The "signature" (as improved on by Simen Kjaeraas) would be:
//----
@property ref T instanceOf( T )( );
//----
But remain un-implemented.

This would ensure it is not actually usable during run-time.

-- 
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