A fresh look at comparisons
Steven Schveighoffer
schveiguy at yahoo.com
Fri Apr 25 10:22:55 PDT 2008
"Bruno Medeiros" wrote
> Steven Schveighoffer wrote:
>>
>> The default opCmp today is:
>>
>> int opCmp(Object o) { return this !is o;}
>>
>
> It is not. For DMD 2.012, it is:
>
> int opCmp(Object o)
> {
> // BUG: this prevents a compacting GC from working, needs to be fixed
> //return cast(int)cast(void *)this - cast(int)cast(void *)o;
>
> throw new Error(cast(string) ("need opCmp for class "
> ~ this.classinfo.name));
> }
>
>
> It's also the same in DMD 1.023 (except without the string cast).
Yes, you are right. I was looking at my tango tree, which I assumed was the
same. Apparently this is a Tango issue, and not a Phobos issue.
Looking at the Phobos tree, it was never this !is o, in fact it changed from
the commented out comparison of memory addresses to the new version in
Phobos 0.163
So I'll post this bug for Tango, and I believe now the system is at least
correct, even if it isn't intuitive for Phobos at least.
-Steve
More information about the Digitalmars-d
mailing list