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

Maciej Izak hnb.code at gmail.com
Tue Feb 2 13:28:47 CET 2016


2016-02-02 13:12 GMT+01:00 Michael Van Canneyt <michael at freepascal.org>:

> "iif(a,b,c)
> is fundamentally different in behaviour from
> functionxyy(a,b,c)"
>
> simply laughable in my eyes, because likely 99,99% of programmers won't
> know the
> difference. As Graeme said: 'I guess I was just lucky it never happened to
> me'.
> That sums it up.
>
> I'm just trying to to put any foaming-at-the-mouth argumentation using
> this particular argument in perspective.
>
> For a correct understanding: The compiler must behave predictable at all
> times, no arguing there. But I don't think that iif() having different
> semantics than all other functions, is a problem. It just needs to be
> documented properly. It is a non-issue for me.
>
> To give more perspective:
> The same is true for Writeln() and Assert(), which also have are different
> semantics, but this difference is simply documented (if at all).
> I didn't hear anyone protesting that. The fact that it is so in the pascal
> standard doesn't make a iota of difference; the standard was most likely
> simply made after the facts.


+1 well said.

profit of different behavior for iif is huge:

x := iif(obj = nil, 0, obj.foo);

and as was stated many times, this behavior iif is *compatible with
existing Oxygene* (!). Finally some compatible part.

maybe is worth to implement additional IfThen intrinsic (just generic
version of regular method from Math/StrUtils.IfThen)

-- 
Best regards,
Maciej Izak
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20160202/ba6e8af6/attachment.html>


More information about the fpc-pascal mailing list