<div dir="auto"><div><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">Hairy Pixels via fpc-devel <<a href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>> schrieb am Do., 28. Aug. 2025, 09:55:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Aug 26, 2025 at 3:49:43 AM, Nikolay Nikolov via fpc-devel <<a href="mailto:fpc-devel@lists.freepascal.org" target="_blank" rel="noreferrer">fpc-devel@lists.freepascal.org</a>> wrote:<br></div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" type="cite">
<div><p>But they're not 100% compatible, are they? IfThen evaluates both
the true and the false parameter, while the 'if' statement
doesn't. For example:</p>
<p>s := IfThen(b <> 0, a div b, 999)</p>
<p>Will raise a division by zero exception, if b is 0, while</p>
<p>s := if b <> 0 then a div b else 999</p>
<p>won't.</p>
<p>Nikolay</p>
</div>
</blockquote>
</div>
<br>
<div dir="ltr">I think if the call was inlined it wouldn’t but otherwise it would. FPC can’t reliably inline either so you wouldn’t want to risk that.</div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">That's wrong. Inlining does *not* change side effects (and if it does that is considered a bug), so parameters are evaluated before the inlined function's code is executed. </div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div dir="ltr"> If that’s a concern then IfThen could be an intrinsic. It’s basically just a macro to a if statement with an assignment. Extremely simple thing to implement.</div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">There had already been an IfThen-intrinisic almost ten years ago, which was then rejected and reverted cause due to its different behavior to a ordinary function would lead to more confusion.</div><div dir="auto"><br></div><div dir="auto">The if-the-expression is just as easy to implement and is now required for Delphi compatibility anyway, so there will not be any discussion about this anymore. </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div dir="auto"><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div></div></div>