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

Michalis Kamburelis michalis.kambi at gmail.com
Mon Feb 1 10:17:04 CET 2016


Maciej Izak wrote:
> +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/ ).

As far as I understand, compatibility is not broken: new IfThen was
deliberately introduced as part of the System unit, that is implicitly
always used as the 1st unit. If you use Math (or StrUtils or any other
modules that provide IfThen implementations), they will "cover" the
System.IfThen definition. So your code will continue to work as it was.

And the name like FpIfThen look rather ugly, actually. As far as I'm
concerned, IfThen sounds simple and Ok.

Michalis



More information about the fpc-pascal mailing list