<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Feb 3, 2016 at 8:11 AM, Serguei TARASSOV <span dir="ltr"><<a href="mailto:serge@arbinada.com" target="_blank">serge@arbinada.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">On 03/02/2016 12:00, <a href="mailto:fpc-pascal-request@lists.freepascal.org" target="_blank">fpc-pascal-request@lists.freepascal.org</a> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Date: Tue, 2 Feb 2016 19:43:02 -0700 (MST)<br>
From: silvioprog<<a href="mailto:silvioprog@gmail.com" target="_blank">silvioprog@gmail.com</a>><span class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
>The problem with Iff() is:1) it either retains normal function behavior<br>
>and thus has to evaluate both expressions (i.e. suboptimal performance and<br>
>allowing side effects);<br>
</blockquote>
Well:<br>
program Project1; function test1: integer; begin WriteLn('A');<br>
Result := 10; end; function test2: integer; begin WriteLn('B');<br>
Result := 20; end; function CommonFunc(A: Boolean; B, C: integer):<br>
integer; begin if A then Result := B else Result := C;<br>
end;var X: LongInt;begin X := IfThen(True, test1, test2); WriteLn(X);<br>
WriteLn('----'); X := CommonFunc(True, test1, test2); WriteLn(X);<br>
ReadLn;end.<br>
Result:<br>
A10----BA10<br>
</span></blockquote>
Holy sh*t, ça continue ! :)<br></blockquote><div><br></div><div>:-)</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Even if evaluation order will be assured and well documented, it doesn't make sense!<br>
Example :<br>
<br>
x := iif(Obj = nil, 0, Obj.Value); // Seems OK when right-to-left and stop on 'true' evalation<br>
x := iif(Obj <> nil, Obj.Value, 0); // Raise access violation</blockquote></div><div><br></div><div>Did you test it? Using the current System.IfThen() it doesn't raises AV for me.<br></div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div>Silvio Clécio</div></div></div>
</div></div>