"==" not symmetric
Lionello Lunesu
lionello at lunesu.remove.com
Tue May 23 13:08:11 PDT 2006
I was checking some sources in the 'internal' folder and saw this:
#int _d_obj_eq(Object o1, Object o2)
#{
# return o1 is o2 || (o1 && o1.opEquals(o2));
#}
truth table:
o1 o2 result
0 0 1
0 x 0
x 0 opEquals, crash?
x x 1
y x opEquals
It's interesting that (o1==o2) is not necessarily the same as (o2==o1)!
Since o1=x,o2=0 returns 0, the other way around should return 0 as well.
I suppose the function should be also check o2, resulting in:
#int _d_obj_eq(Object o1, Object o2)
#{
# return o1 is o2 || (o1 && o2 && o1.opEquals(o2));
#}
L.
More information about the Digitalmars-d
mailing list