<p>Am 02.02.2016 11:12 schrieb "Serguei TARASSOV" <<a href="mailto:serge@arbinada.com">serge@arbinada.com</a>>:<br>
><br>
> On 02/02/2016 10:54, <a href="mailto:fpc-pascal-request@lists.freepascal.org">fpc-pascal-request@lists.freepascal.org</a> wrote:<br>
><br>
>> On Tue, 2 Feb 2016, Michael Van Canneyt wrote<br>
>>><br>
>>><br>
>>> On Tue, 2 Feb 2016, Serguei TARASSOV wrote: > No, the second is always better because safer.<br>
>>><br>
>>> ><br>
>>> >x := iif (Obj = nil, 0, Obj.Value);<br>
>>> >This will raise access violation as a normal function or you depend on<br>
>>> >compiler implementation for this special case. And you should remember an<br>
>>> >additional special case of function.<br>
>>> ><br>
>>> >x := iif Obj = nil then 0 else Obj.Value;<br>
>>> >Doesn't raise AV because it's a statement, not function.<br>
>><br>
>> It is not a statement, it is an expression.<br>
><br>
> ???<br>
> iif is a new statement "inline if".</p>
<p>No, it's an expression, not a statement.</p>
<p>> It contains other statements "then" "else"</p>
<p>No, these are keywords.</p>
<p>> It returns a value like an assignment statement ":=" in Pascal or "return" in C-like languages.</p>
<p>That's why it is an expression. Statements don't return values.</p>
<p>> It may be used without assignment:<br>
><br>
> {$IFDEF DEBUG}<br>
> x :=<br>
> {$ENDIF}<br>
> iif Obj = nil then 0 else Obj.DoSomethingAndReturnValue;</p>
<p>No, because "0" is not a valid statement.</p>
<p>Regards,<br>
Sven</p>