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

Sven Barth pascaldragon at googlemail.com
Tue Feb 2 17:49:24 CET 2016


Am 02.02.2016 16:11 schrieb "Martin" <fpc at mfriebe.de>:
>
> On 02/02/2016 13:24, Sven Barth wrote:
>>
>>
>> > Look at the "iif" as an statement and the things will be simple.
>>
>> BECAUSE. IT. IS. *NOT*. A. STATEMENT!
>> It never was and it never will be! It returns a value and thus by
definition it is an expression!
>>
>>
> +1
> And imho that why it is important that it does not look like a statement
either, i.e. it does not start with a keyword.
>
> also if we are discussing (are we?) a form like
>   x:= iIf a>b  iThen c iElse b;
> then why not
>   x:=  a>b  ifThen c ifElse b;

Because I won't add new keywords just for this feature, especially if they
are inside normal code (I'm a bit less strict outside of routine bodies ;)
).

Also in your second case especially the "ifThen" needs to be handled as an
operator to avoid too big modifications of the parser that I don't see
justified for something that should merely be a minor extension.

> What are the advantages/disadvantages they have over each other?

The former is much more easy to add as my patch in the "if-then-else
expression" thread shows. The other will be be more complicated.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20160202/10b38660/attachment.html>


More information about the fpc-pascal mailing list