https://d.puremagic.com/issues/show_bug.cgi?id=11683

           Summary: Document current Identity Expression over `interface`s
                    behaviour
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: websites
        AssignedTo: nob...@puremagic.com
        ReportedBy: verylonglogin....@gmail.com


--- Comment #0 from Denis Shelomovskij <verylonglogin....@gmail.com> 2013-12-04 
21:12:28 MSK ---
Because of Issue 4979 implementing an interface twice results in different
references dependent on cast order.

Currently Identity Expression over two `interface`s just compare pointers and
over an `interface` and a `class` it adds a constant dependent on operands CT
types to `class` reference and then compare pointers:
---
interface I {}
class A: I {}
class B: A, I {}

void main() @safe
{
    B b = new B;
    A a = b;
    I ia = a, ib = b;
    assert(ia is a);   // ok
    assert(ib is b);   // ok
    assert(ia is b);   // fails
    assert(ib is a);   // fails
    assert(ia is ib);  // fails
}
---

Thus Identity Expression has nothing to do with "the object references are for
the same object" except the case of two classes unless Issue 4979 is fixed.

If Issue 4979 isn't going to be fixed in the immediate future Identity
Expression over `interface`s should be appropriately documented and possibly
deprecated.

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

Reply via email to