[fpc-devel] new features and facilities

Sven Barth pascaldragon at googlemail.com
Fri Oct 9 23:04:41 CEST 2015


Am 09.10.2015 20:29 schrieb "Michael Van Canneyt" <michael at freepascal.org>:
>
>
>
> On Fri, 9 Oct 2015, Dmitry Boyarintsev wrote:
>
>> The only Pascal way is
>>
>> left := IfThen(expr1, expr2, expr3)
>>
>> Similar to addr(), sizeof(), length(), write() and recently added
Default()
>> in intrinsic.
>> I guess functions declared in Math unit are not covering all the needs
>> (since type of expr2, expr3) may vary.
>> That's why a bit of compiler support is needed.
>
>
> The main reason compiler support is needed is that Expr3 must not be
evaluated if expr1 is true, and expr2 must not be evaluated if expr1 is
false, at least if you want the ternary semantics. (as once explained to me
by Sven himself...)
>
> I'm not sure this kind of semantics is possible with a compiler
intrinsic...
> But if it is: In that case the IfThen or IIF() or somesuch has my
absolute top preference, followed by ternary. (and the If .. then
expression should be blasted to hell ;) )

Yes a compiler intrinsic could handle that. In the end all three syntaxes
are the same code representation anyway: namely an if-node.
The IfThen() intrinsic would be fine with me as well. Let's call this our
common ground ;)

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20151009/99980ab1/attachment.html>


More information about the fpc-devel mailing list