[fpc-pascal] New feature: IfThen() intrinsic
silvioprog
silvioprog at gmail.com
Tue Feb 2 13:01:01 CET 2016
On Tue, Feb 2, 2016 at 6:49 AM, Michael Van Canneyt <michael at freepascal.org>
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.
>
> I prefer
> x := iif Obj = nil then 0 else Obj.Value;
> over
> x := if Obj = nil then 0 else Obj.Value;
>
> Because it clearly differentiates between if (a statement) and iif (an
> expression)
>
> So the iif in either functional or expression form has my vote.
+1. The function is more clear to me too.
--
Silvio Clécio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20160202/01c811f5/attachment.html>
More information about the fpc-pascal
mailing list