digitalmars.D.learn - Cannot compare shared Objects
- Jacob Carlborg (18/18) Sep 12 2010 The following example doesn't compile with D2:
- Simen kjaeraas (7/24) Sep 12 2010 You're absolutely right about the cause. This is related to, though not ...
- Jacob Carlborg (4/31) Sep 13 2010 Filed as http://d.puremagic.com/issues/show_bug.cgi?id=4857
- Steven Schveighoffer (15/43) Sep 13 2010 Not exactly right. Comparing two objects has been altered significantly...
The following example doesn't compile with D2: class Foo { private Object value; synchronized bool hasValue (Object val) { return value == val; } } It gives the error: main.d(11): Error: function object.opEquals (Object lhs, Object rhs) is not callable using argument types (shared(Object),Object) main.d(11): Error: cannot implicitly convert expression (this.value) of type shared(Object) to object.Object Is that because object.opEquals hasn't been overloaded with a shared version yet? If that's the case has this already been reported in bugzilla? -- /Jacob Carlborg
Sep 12 2010
Jacob Carlborg <doob me.com> wrote:The following example doesn't compile with D2: class Foo { private Object value; synchronized bool hasValue (Object val) { return value == val; } } It gives the error: main.d(11): Error: function object.opEquals (Object lhs, Object rhs) is not callable using argument types (shared(Object),Object) main.d(11): Error: cannot implicitly convert expression (this.value) of type shared(Object) to object.Object Is that because object.opEquals hasn't been overloaded with a shared version yet? If that's the case has this already been reported in bugzilla?You're absolutely right about the cause. This is related to, though not the bug. -- Simen
Sep 12 2010
On 2010-09-12 23:00, Simen kjaeraas wrote:Jacob Carlborg <doob me.com> wrote:Filed as http://d.puremagic.com/issues/show_bug.cgi?id=4857 -- /Jacob CarlborgThe following example doesn't compile with D2: class Foo { private Object value; synchronized bool hasValue (Object val) { return value == val; } } It gives the error: main.d(11): Error: function object.opEquals (Object lhs, Object rhs) is not callable using argument types (shared(Object),Object) main.d(11): Error: cannot implicitly convert expression (this.value) of type shared(Object) to object.Object Is that because object.opEquals hasn't been overloaded with a shared version yet? If that's the case has this already been reported in bugzilla?You're absolutely right about the cause. This is related to, though not the bug.
Sep 13 2010
On Sun, 12 Sep 2010 17:00:54 -0400, Simen kjaeraas <simen.kjaras gmail.com> wrote:Jacob Carlborg <doob me.com> wrote:Not exactly right. Comparing two objects has been altered significantly since a few versions ago. Instead of a = b translating to a.opEquals(b), it translates to opEquals(a, b). opEquals(a, b) is defined in object.di as: bool opEquals(Object o1, Object o2); This means you cannot compare shared, immutable, or const objects, and you cannot compare interfaces (because interfaces do not implicitly cast to Object). Even if you updated Object.opEquals, it still wouldn't work. It is a severe problem that has been ignored for quite a while (especially the interface comparison problem). The interface bug report: http://d.puremagic.com/issues/show_bug.cgi?id=4088 -SteveThe following example doesn't compile with D2: class Foo { private Object value; synchronized bool hasValue (Object val) { return value == val; } } It gives the error: main.d(11): Error: function object.opEquals (Object lhs, Object rhs) is not callable using argument types (shared(Object),Object) main.d(11): Error: cannot implicitly convert expression (this.value) of type shared(Object) to object.Object Is that because object.opEquals hasn't been overloaded with a shared version yet? If that's the case has this already been reported in bugzilla?You're absolutely right about the cause. This is related to, though not the bug.
Sep 13 2010