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