Skybuck Flying
2015-02-12 00:58:52 UTC
Hello,
Delphi XE 7 behaves inconsistent concerning function result "build up":
// CASE 1 (AND): will always call all functions !
function Example1 : boolean;
begin
result := True;
result := result and FunctionA;
result := result and FunctionB;
result := result and FunctionC;
end;
// CASE 2 (OR): short boolean evaluation makes this code fail ! once
functionA returns true, the other 2 functions will not called !
function Example2 : boolean;
begin
result := False;
result := result or FunctionA;
result := result or FunctionB;
result := result or FunctionC;
end;
// This kind of inconsistent behaviour is bad !!!
// Recommendation: Always execute functions which are called on "boolean
chains !"
Bye,
Skybuck.
Delphi XE 7 behaves inconsistent concerning function result "build up":
// CASE 1 (AND): will always call all functions !
function Example1 : boolean;
begin
result := True;
result := result and FunctionA;
result := result and FunctionB;
result := result and FunctionC;
end;
// CASE 2 (OR): short boolean evaluation makes this code fail ! once
functionA returns true, the other 2 functions will not called !
function Example2 : boolean;
begin
result := False;
result := result or FunctionA;
result := result or FunctionB;
result := result or FunctionC;
end;
// This kind of inconsistent behaviour is bad !!!
// Recommendation: Always execute functions which are called on "boolean
chains !"
Bye,
Skybuck.