<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p><br>
</p>
<div class="moz-cite-prefix">On 8/25/25 5:27 PM, Hairy Pixels via
fpc-devel wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAGsUGt=bXQW6yekHdLPWG20yULdBfayz2mf=gHBkfStAJ1kcVw@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Aug 24, 2025 at 3:28:45 PM,
Karoly Balogh via fpc-devel <<a
href="mailto:fpc-devel@lists.freepascal.org"
moz-do-not-send="true" class="moz-txt-link-freetext">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>The new syntax has strong Python vibes to me. This is
where I saw/used<br>
this the most. Which is not necessarily a bad thing. My code
is usually<br>
very oldschool and I tend to avoid most of the "modern"
bells & whistles,<br>
as I have a firm belief they hinder long-term
maintainability, or they're<br>
simply eye-sore (mainly that Delphi inline variable
declaration comes to<br>
mind) but this is one of the "newschool" syntax things which
I'd gladly<br>
use myself.</div>
</blockquote>
</div>
<br>
<div dir="ltr">I think they added a IfThen generic which can be
implicitly specialized now so you can do things like:</div>
<div dir="ltr"><br>
</div>
<div dir="ltr"> s := IfThen(p <> nil, 'valid', 'nil’);</div>
<div dir="ltr"> </div>
<div dir="ltr">vs </div>
<div dir="ltr"><br>
</div>
<div dir="ltr"> s := If p <> nil then 'valid' else 'nil';<br>
</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">It’s almost easier to read. I’m not sure I’d like
the have if-statements confused with expressions when scanning
code either. At least the C version is more terse but that one
can be hard to identify also. All in all I think IfThen is
actually pretty good.</div>
</blockquote>
<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>
</body>
</html>