[fpc-pascal] New feature: IfThen() intrinsic

silvioprog silvioprog at gmail.com
Tue Feb 2 12:54:19 CET 2016


On Tue, Feb 2, 2016 at 6:07 AM, Michael Van Canneyt <michael at freepascal.org>
wrote:

> On Tue, 2 Feb 2016, Maciej Izak wrote:
>
>> we can even mix to gain more clear code:
>>
>> foo :=
>>  if Condition1 then
>>    iif(Condition2, ThenExpr1, ElseExpr1)
>>  else
>>    iif(Condition3, ThenExpr2, ElseExpr2);
>>
>> much more readable than:
>>
>
> Call me old fashioned, but then I think
>

I don't think you are old fashioned. :-)


>   foo:=iif(Condition1,
>            iif(Condition2, ThenExpr1, ElseExpr1),
>            iif(Condition3, ThenExpr2, ElseExpr2));
> is more clear.
>

+1.


> The "if then" construct is really confusing.
> "if then" is a statement, not an expression.


I think strange this logic on the code above, and I totally agree with you.
If it was accepted to ObjFPC, it would be the first language to accepet an
`if` statement as an expression, sounding as an abbreviation in the
language.

-- 
Silvio Clécio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20160202/1e9fc32c/attachment.html>


More information about the fpc-pascal mailing list