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

David Butler djbutler at gmail.com
Mon Feb 1 09:35:21 CET 2016


This is usually called "inline if".

Maybe call it "inlineif" or "iif", e..g

x := iif (a < 3, 1, 2)

or even

x := iif a < 3 then 1 else 2;


On Mon, Feb 1, 2016 at 10:26 AM, Maciej Izak <hnb.code at gmail.com> wrote:

> 2016-02-01 8:59 GMT+01:00 Marco van de Voort <marcov at stack.nl>:
>
>> The only really bad thing is the name, as Florian already said, with the
>> versions in strutils and math.  The clash with delphi compatible functions
>> should be avoided.
>
>
> +1 . IfThen instricit is IMO very bad idea. I have a lot of "IfThen" from
> math and strutils modules.
>
> IfThen from System totally breaks the compatibility :\ . C'mon Sven. In
> one field you're rigorously but in something like this you're liberal
> (braking/dangerous change / for existing code base).
>
> If i understand correctly "ThenExpr" is executed only when "Condition" is
> true and "ElseExpr" is executed only when "Condition" is false. For
> standard "IfThen" from Math and StrUtils "ThenExpr" and "ElseExpr" is
> executed before IfThen is called.
>
> for me different syntax for System.IfThen is required (fpIfThen ? or
> http://docs.elementscompiler.com/Oxygene/Expressions/If/ ).
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20160201/2b2a6654/attachment.html>


More information about the fpc-pascal mailing list