by CarlRanson >> Thu, 16 Jan 2003 3:55:20 GMT
We've just been bitten by a bug in some code we inherited that effectively boils down to the following:
given classes Foo & Bar , both descended from Object.
var
foo : Foo;
bar : Bar;begin
....(some code).
if foo=bar then
// code we expected to get called that didn't.
endif;
end;
Consider that foo and bar are on different branches of the class hierarchy, i.e. foo.isKindOf(Bar) = bar.isKindOf(Foo) = false
Does it really make sense for this comparison to be allowed by the compiler? The only time it could EVER evaluate to true is if foo=bar=null which pretty much all developers would code as if foo=null and bar=null then (do something useful).
Surely it makes more sense that if comparisons are only allowed where assignments would be as well.....(note that foo:=bar would be a 6072 error at compile time).
So for a=b to be valid, either a must be descendant of b or b must be a descendant of a.
Opinions?
CR