Bug 11683 – Document current Identity Expression over `interface`s behaviour

Status
NEW
Severity
major
Priority
P2
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-12-04T09:12:28Z
Last change time
2024-12-15T15:22:28Z
Assigned to
No Owner
Creator
Denis Shelomovskii
Moved to GitHub: dlang.org#3940 →

Comments

Comment #0 by verylonglogin.reg — 2013-12-04T09:12:28Z
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.
Comment #1 by robert.schadek — 2024-12-15T15:22:28Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dlang.org/issues/3940 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB