[fpc-pascal] if-then-else expression
silvioprog
silvioprog at gmail.com
Wed Feb 3 03:43:02 CET 2016
etrusco wrote
> On Feb 2, 2016 7:41 PM, "geneb" <
> geneb@
> > wrote:
> [...]
> The problem with Iff() is:1) it either retains normal function behavior
> and thus has to evaluate both expressions (i.e. suboptimal performance and
> allowing side effects);
Well:
program Project1; function test1: integer; begin WriteLn('A');
Result := 10; end; function test2: integer; begin WriteLn('B');
Result := 20; end; function CommonFunc(A: Boolean; B, C: integer):
integer; begin if A then Result := B else Result := C;
end;var X: LongInt;begin X := IfThen(True, test1, test2); WriteLn(X);
WriteLn('----'); X := CommonFunc(True, test1, test2); WriteLn(X);
ReadLn;end.
Result:
A10----BA10
--
View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Re-if-then-else-expression-tp5723834p5723966.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20160202/30a1e2a4/attachment.html>
More information about the fpc-pascal
mailing list