Hello,

can somebody comment on the Remark from https://www.freepascal.org/docs-html/ref/refch12.html ? /Remark: The order in which expressions of the same precedence are evaluated is not guaranteed to be left-to-right./

Is this valid for boolean expressions, too? I use the following construct with {$BOOLEVAL OFF}:
Result := Assigned(MyObject) and (MyObject.Value>5);
The remark above suggests that I cannot use it because (MyObject.Value>5) may be evaluated before Assigned(MyObject) if the optimizer decides so.

On the other hand, the information in https://www.freepascal.org/docs-html/current/prog/progsu4.html#x11-100001.2.4 suggests the opposite: /So, in the following example, the function Bofu, which has a boolean result, will never get called.//
//If False and Bofu then/

Delphi documentation also explicitly states that the expressions are evaluated in left to right order: http://docwiki.embarcadero.com/RADStudio/Rio/en/Boolean_short-circuit_evaluation_(Delphi_compiler_directive)

(Well it is no surprise because https://www.freepascal.org/docs-html/ref/refch12.html states that "/This behaviour is distinctly different from Delphi or Turbo Pascal./")

Ondrej

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to