[fpc-pascal] New feature: IfThen() intrinsic
Maciej Izak
hnb.code at gmail.com
Tue Feb 2 08:31:47 CET 2016
2016-02-02 8:22 GMT+01:00 Maciej Izak <hnb.code at gmail.com>:
> 2016-02-01 10:59 GMT+01:00 Michael Schnell <mschnell at lumino.de>:
>
>> On 02/01/2016 09:35 AM, David Butler wrote:
>>
>>>
>>>
>>> Maybe call it "inlineif" or "iif", e..g
>>>
>>> x := iif (a < 3, 1, 2)
>>>
>>> It's iif in Oxygen. So why not keep that name ?
>
>
> Same here. I see no reason to differ from it. Introducing new
> incompatibility is bad idea. For me is good to have booth (Oxygene
> compatible):
>
> x := iif (a < 3, 1, 2);
> V := If a < 3 then 1 else 2;
>
> sometimes is better to use first option and sometimes is better to use
> second option. Both Oxygen compatible and very "pascalish".
>
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:
if Condition1 then
begin
if Condition2 then
foo := ThenExpr1
else
foo := ElseExpr1
end else
begin
if Condition3 then
foo := ThenExpr2
else
foo := ElseExpr2
end;
--
Best regards,
Maciej Izak
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20160202/85c68c5a/attachment.html>
More information about the fpc-pascal
mailing list